Skip to content

Conversation

@jaekwon
Copy link

@jaekwon jaekwon commented Dec 20, 2011

this fix will become obsolete when the node-mongodb dependency gets removed,
but here's a fix that worked for me in case others need it now.

@marcello3d
Copy link
Owner

Is there some way we can build a test case for this? I'm not entirely convinced that the problem goes away with the new code branch.

@jaekwon
Copy link
Author

jaekwon commented Dec 25, 2011

The problem is a collection of the following:

  1. 'server = new Server()' will call scanServer, which sends a command to 'admin'.
  2. my code happened to want to quit immediately after creating a Server (in the same event loop), because there were no indices to ensure.
  3. calling 'server.close()' immediately upon Server creation hangs because the 'admin' command from (1) didn't respond yet, which means taxman didn't have a chance to set .value.

Testing is not easy, the failure effect is that typical node scripts will hang (I guess because the server connection is open), whereas nodeunit may be forcing an exit() once all the test.done() have been called.

You can easily test hanging on the console with the following script.

var Mongolian = require('./mongolian')
var db = new Mongolian('mongo://localhost/mongolian_test', { log:false })
var hang = true

if (hang) {

  db.dropdatabase(function(error) {
  })
  db.server.close()

} else {

  db.dropdatabase(function(error) {
    db.server.close()
  })

}

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