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

Failed .connect() hangs Node for 30 seconds #6028

Closed
salieri opened this issue Jan 22, 2018 · 2 comments
Closed

Failed .connect() hangs Node for 30 seconds #6028

salieri opened this issue Jan 22, 2018 · 2 comments
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. underlying library issue This issue is a bug with an underlying library, like the MongoDB driver or mongodb-core
Milestone

Comments

@salieri
Copy link

salieri commented Jan 22, 2018

Tested on 5.0.1 and Node 8.9.4

const mongoose = require( 'mongoose' );
const m = new mongoose.Mongoose();

m.connect( 'mongodb://thisdoesntexist:27017' )
  .then(
    () => { console.log( 'Success!' ); },
    ( err ) => { console.error( err ); }
  );

Results:

  1. Promise is rejected pretty much immediately. (As expected)
  2. Node.js process hangs (=does not exit) for 30 seconds. (Not expected)

Intuitive expectation would be that connection process comes to an end when the .connect() promise is rejected. Seems like something keeps going on in the background after that, though.

@sobafuchs
Copy link
Contributor

sorry I've deleted my previous comment, i was able to reproduce this actually. To clarify, the node process in this script shouldnt hang for 30 seconds, it should exit immediately. I've even tried passing reconnectTries: 0 to the connection options, and it still hangs:

const mongoose = require( 'mongoose' );
const m = new mongoose.Mongoose();

m.connect( 'mongodb://thisdoesntexist:27017', { reconnectTries: 0, useMongoClient: true } )
  .then(
    () => { console.log( 'Success!' ); },
    ( err ) => { console.error( err ); }
  );

@sobafuchs sobafuchs added the confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. label Jan 27, 2018
@sobafuchs sobafuchs added this to the 5.0.3 milestone Jan 27, 2018
@vkarpov15 vkarpov15 modified the milestones: 5.0.3, 5.0.4 Feb 1, 2018
@vkarpov15 vkarpov15 added the underlying library issue This issue is a bug with an underlying library, like the MongoDB driver or mongodb-core label Feb 4, 2018
@vkarpov15
Copy link
Collaborator

Tracked this down to a bug in the mongodb driver and put in a patch with some questions, see mongodb-js/mongodb-core#275

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. underlying library issue This issue is a bug with an underlying library, like the MongoDB driver or mongodb-core
Projects
None yet
3 participants