question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Callbacks Stop Happening

See original GitHub issue

I’ve been using mongoose for a few years, but lately I’m having a lot of trouble where the connection seems to disappear.

Connection Settings

// Connecting to MongoDB 3.2.1
var connString = "mongodb://xxxxx:xxxxx@xxxxx:xxxx,xxxx:xxxx/xxx?ssl=true";
var connOptions = {
  "mongos": { "ssl": true, "sslValidate": false }
};
mongoose.connect(connString, connOptions, function(err, db) {
  if(err) { console.log("Error connecting to db: "+err); }
});

The Problem

Mongoose just stops calling back. It doesn’t emit any errors, memory/cpu is fine on my server & db, and I can connect from any other server. Restarting always fixes it:

db.Something.count({}, callback);

Versions

On mongoose 4.4.11, mongoose.connection.readyState === UNAUTHORIZED when callbacks stop.

So I upgraded to mongoose 4.6.0 but within 4 hours the callbacks stopped again, now with mongoose.connection.readyState === CONNECTED.

Any Ideas

Any ideas how I can get this to stop happening?

I’m happy to gather any more debugging info, just let me know what info to get.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:53 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
vkarpov15commented, Oct 8, 2017

Unfortunately gonna have to push this one back again because mongodb driver is held up from releasing. Sorry about that and thanks for your patience 👍 🌴

1reaction
adriaanmeuriscommented, Aug 21, 2017

thanks for testing! Indeed Mongoose always stays connected, but callbacks stop happening (you can see the request coming into Express, but they’ll timeout)

I was testing with:

  • node 6.8.1
  • mongodb 2.2.30
  • mongoose 4.11.5

I’ve updated to:

  • node 6.8.1
  • mongodb 2.2.31
  • mongoose 4.11.7

I can still reproduce the issue locally with the first script I posted. It only occurs when a Mongo connection times out, so you might want to change the query that simulates this:

mongoose.model('Test').find({$where: 'sleep(10000) || true'})

(I’m not sure if this will trigger a timeout on every machine so a change to this query might be necessary to reproduce)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to stop training a neural-network using callback?
In this brief tutorial, we learn how to stop training a Deep Neural Network in Tensorflow and Keras, using the callback approach, ...
Read more >
What is the difference between TensorFlow's callbacks and ...
A callback function (e.g. early stopping) is a function that is passed as an argument to another function (e.g. fitting an ML model),...
Read more >
Use Early Stopping to Halt the Training of Neural Networks At ...
The EarlyStopping callback will stop training once triggered, but the model at the end of training may not be the model with best...
Read more >
tf.keras.callbacks.EarlyStopping | TensorFlow v2.11.0
Stop training when a monitored metric has stopped improving. ... This callback will stop the training when there is no improvement in
Read more >
EarlyStopping callback behaving mysteriously in Keras
I think your interpretation of the EarlyStopping callback is a little off; it stops when the loss doesn't improve from the best loss...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found