Skip to content
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

Handle undefined db on connect #5

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

nearwood
Copy link

@nearwood nearwood commented Aug 30, 2016

Added an if statement to check if db is defined before attempting to use it in the connect method. Also added an option for skipping errors on insert in included commits but removed them. Removed connection string config from error message, to rely just on MongoDB error object for debugging (relevant to my project).

So, basically, just added the db check to the connect method. Feel free to skip the other stuff, I was just prototyping some stuff for a project.

@4kochi
Copy link
Collaborator

4kochi commented Aug 30, 2016

Thanks for the pull request. I guess I will merge the db check. Just out of curiosity. What is your scenario that MongoClient.connect() callback is called with no error, but the db object is null or undefined. Sounds like a weird combination.

@nearwood
Copy link
Author

nearwood commented Oct 3, 2016

There was an error, but the connect() method continues to try and use the db object that may not be defined. So, you could also return in the if (err) conditional block for the same effect.

Sorry for the delayed response, I'm not getting notifications anymore :(

@4kochi
Copy link
Collaborator

4kochi commented Oct 3, 2016

Ok, no problem. Thanks for the clarification. I will merge the pr after my vacation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants