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

Avoid trapped in db connecting state if mistakenly call db.open first and server connect afterward. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kenspirit
Copy link

Avoid trapped in db connecting state if mistakenly call db.open first and server connect afterward.

Client insert command will keep pushing to commands list if db._state is always connecting and set to autoreconnect.

Line 1886 in db.js method Db.prototype._executeInsertCommand:
if(self._state == 'connecting' && this.serverConfig.autoReconnect)

… and server connect afterward.

Client insert command will keep pushing to commands list if db._state is always connecting and set to autoreconnect.
@christkv
Copy link
Owner

christkv commented Dec 3, 2012

Why are you calling db.open and server.connect. Server connect should never be called by your code

@kenspirit
Copy link
Author

Hi Christian,

Thanks for confirming me that Server connect should never be called by our
code.
This issue is found when I am using the connect-mongodb(
https://github.com/masylum/connect-mongodb) and hit that.

I think I might also submit fix to them or notify the owner.
However, I also think that because this method in reality now can be
mistakenly called by others, if that is your design decision, maybe it's
better to state in document more clearly or make the Server connect private
to outside.

BTW, I would like to ask you a question regarding what is the most
appropriate way for mongodb connection management in nodejs.
I saw your reply in
http://stackoverflow.com/questions/10307994/where-can-i-find-complete-documentation-concerning-node-mongodb-native/10349450#10349450
:
DO NOT call open on each request

I think then we should wrap the nodejs app server startup in the callback
of db.open method for connection pool sharing?

But I saw another reply in
http://stackoverflow.com/questions/10656574/how-to-manage-mongodb-connections-in-a-nodejs-webapp
This looks strange and make me confusing.

I wonder whether the document for nodejs-mongodb-native should document
this issue more clearly.
Thanks.

On Tue, Dec 4, 2012 at 6:53 AM, Christian Amor Kvalheim <
notifications@github.com> wrote:

Why are you calling db.open and server.connect. Server connect should
never be called by your code


Reply to this email directly or view it on GitHubhttps://github.com//pull/3#issuecomment-10976166.


Ken Chen

@maccolman
Copy link

Hello I have installed on my system.
When I run this http://localhost:3000.
Then I gets a message "Not Implemented".

Can you guide me what i am doing wrong?
Thanks

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