Welcome to the new MongoDB Feedback Portal!
{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.
We’ve upgraded our feedback system to better capture, track, and act on your feedback. Here’s what you need to know:
Just an update that is quite relevant: The mongoose library, which relies on the Node.js driver for MongoDB, has issued a healthcheck fix for version 8.7.x as described here in this pull request: https://github.com/Automattic/mongoose/pull/14812 This will definitely help the stale connection issue above, but we will have to see if that resolves all of the issues experienced.
Thanks for the suggestion Kevin! Just for additional context, this type of connection health checking is typically done automatically by the MongoClient when a connection is checked out of the connection pool and used. If the checked out connection cannot be used successfully (such as the underlying connection being closed), it will be discarded and a new connection created in it's place. Connection health checking (such as using [Mongoose's `readyState`](https://mongoosejs.com/docs/api/connection.html#Connection.prototype.readyState) can potentially misreport health as a result of the underlying execution environment (ex: Lambda) freezing/thawing between invokations, resulting in possible internal state inconsistencies. I've filed [this ticket](https://github.com/Automattic/mongoose/issues/14727) for Mongoose specifically, but we will continue to look for ways to improve the developer experience of our drivers in these stateless environments as well. Note that [Mongoose's Lambda docs](https://mongoosejs.com/docs/lambda.html) don't use `readyState` and also rely on the underlying driver's connection management mechanism.