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

Blocker - Mongoose v4.9.9 hangs on call to connect() #5249

Closed
erezool opened this issue May 15, 2017 · 7 comments
Closed

Blocker - Mongoose v4.9.9 hangs on call to connect() #5249

erezool opened this issue May 15, 2017 · 7 comments
Milestone

Comments

@erezool
Copy link

erezool commented May 15, 2017

It simply hangs during the mongoose.connect() (callback is never called)

@cortezcristian
Copy link

Same here, had to downgrade to v4.9.8

@jeffwhelpley
Copy link

Same here. downgraded.

@sshen81
Copy link

sshen81 commented May 16, 2017

Same issue. As a workaround, using promises resolved it for me.

@sobafuchs
Copy link
Contributor

sobafuchs commented May 16, 2017

Hm, that's weird. The callback executes for me:

const mongoose = require('mongoose');
const co = require('co');
mongoose.Promise = global.Promise;
const GITHUB_ISSUE = `gh-5249`;


exec();

function exec() {
  mongoose.connect(`mongodb://localhost:27017/${GITHUB_ISSUE}`, function() {
    co(function* () {
      const schema = new mongoose.Schema({
        name: String
      });


      const Model = mongoose.model('Model', schema);

      yield Model.remove({});

      const doc = yield Model.create({ name: 'test' });

      console.log('successfully created doc');
    }).catch(error => console.error(error));
  });
}

Can you try this script and see if it works? If not, could I see the context in which your mongoose.connect call hangs?

@sobafuchs sobafuchs added the can't reproduce Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity. label May 16, 2017
@erezool
Copy link
Author

erezool commented May 16, 2017

Apologies, I apparently did not mention important information:

  • I overwrite mongoose default Promise to bluebird
  • I try to connect to a replica set

Here's a reproducible example:

var mongoose = require('mongoose');
var bluebird = require('bluebird');

mongoose.Promise = bluebird;

var conn = 'mongodb://primary,secondary/test?replicaSet=test';
mongoose.connect(conn, function(err, result) {
        console.error('Error:', err);
});

Notice that I don't even use a promise notation for the connect.
Actual result: code hangs and console.error never printed.

@jeffwhelpley
Copy link

I am having the issue and I connect to a replica set as well. I do not override the promise library, but promises are hanging.

@vkarpov15 vkarpov15 removed the can't reproduce Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity. label May 18, 2017
@vkarpov15 vkarpov15 added this to the 4.9.10 milestone May 18, 2017
@vkarpov15
Copy link
Collaborator

Fixed, my sincerest apologies for the trouble, some of the refactoring work for #5229 made it so that the callback to mongoose.connect() doesn't get called in 4.9.9. Mongoose does connect successfully, it just doesn't call the callback. Will release 4.9.10 immediately to fix this issue 👍

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

No branches or pull requests

6 participants