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
MongoNetworkTimeoutError crashes nodejs process #14377
Comments
Need more details. What's your connection string look like. What else are you doing? |
I want to say that when there's a connection error, The error should be catchable instead of crashing the process, without asking why the connection timed out. |
t looks like the following script throws an uncaught error, we're investigating 'use strict';
const mongoose = require('mongoose');
const conn = mongoose.createConnection('mongodb://fail:27017/mongoose_test', { serverSelectionTimeoutMS: 1000 });
conn.on('error', err => console.log('Error hander', err)); |
In general, we would recommend handling errors using |
…rror') handler registered Fix #14377
fix(connection): avoid unhandled error on createConnection() if on('error') handler registered
Prerequisites
Mongoose version
8.2.0
Node.js version
19.4.0
MongoDB server version
6.2.0
Typescript version (if applicable)
5.2.2
Description
MongoNetworkTimeoutError
crashes my process even though I catch the error withconnection.on( 'error', () => {} )
.The
error
event is triggered while the server isn't reachable, but the process is crashed.Steps to Reproduce
Expected Behavior
No response
The text was updated successfully, but these errors were encountered: