-
Notifications
You must be signed in to change notification settings - Fork 35
fix: bad auth error #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: bad auth error #178
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request addresses authentication issues by implementing a retry mechanism for connecting to the MongoDB cluster and making user deletion asynchronous.
- Introduces a retry loop for connecting to MongoDB in connectCluster.ts.
- Adjusts user deletion in session.ts to run asynchronously to prevent timeouts.
- Adds a new logging identifier in logger.ts to support the retry mechanism.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/tools/atlas/metadata/connectCluster.ts | Adds a retry loop for connecting to MongoDB with logging on failure |
src/session.ts | Refactors user deletion to be asynchronous using promise chaining |
src/logger.ts | Adds a new logging identifier for connection failures |
|
||
await this.session.connectToMongoDB(connectionString, this.config.connectOptions); | ||
for (let i = 0; i < 20; i++) { | ||
try { | ||
await this.session.connectToMongoDB(connectionString, this.config.connectOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If all retry attempts fail, the connection error is silently swallowed. Consider throwing an error or returning a failure state after exhausting all attempts.
await this.session.connectToMongoDB(connectionString, this.config.connectOptions); | |
for (let i = 0; i < 20; i++) { | |
try { | |
await this.session.connectToMongoDB(connectionString, this.config.connectOptions); | |
let connected = false; | |
for (let i = 0; i < 20; i++) { | |
try { | |
await this.session.connectToMongoDB(connectionString, this.config.connectOptions); | |
connected = true; |
Copilot uses AI. Check for mistakes.
let lastError: Error | undefined = undefined; | ||
|
||
for (let i = 0; i < 20; i++) { | ||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we add tests for this in a follow-up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the integration tests we can't force a user to take longer to be created, we could try with unit tests, but none of the tools are covered in unit at the moment
This essentially keeps trying to connect because after user is created it might take some time for it to be available.
note: also making deletion of user async on disconnect to reduce change of timeout