Skip to content

Commit 03d6b29

Browse files
committed
Ignoring error event in connect handler if callback is null
1 parent 5505417 commit 03d6b29

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/mongodb/connection/server.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,9 @@ Server.prototype.connect = function(dbInstance, options, callback) {
210210
// ensure no callbacks get called twice
211211
var internalCallback = callback;
212212
callback = null;
213-
// if no internal callback set emit an error
214-
if(err != null && typeof internalCallback !== 'function') {
215-
return eventReceiver.emit("error", new Error("connection failure, socket timed out or was reset"), server);
216-
}
217-
213+
// If something close down the connection and removed the callback before
214+
// proxy killed connection etc, ignore the erorr as close event was isssued
215+
if(err != null && internalCallback == null) return;
218216
// Internal callback
219217
if(err != null) return internalCallback(err, null);
220218
server.master = reply.documents[0].ismaster == 1 ? true : false;

0 commit comments

Comments
 (0)