Skip to content

Commit dbfe4f5

Browse files
committed
refactor: check err.code exists before checking if its in a set
1 parent 4ec04f0 commit dbfe4f5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/core/error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ function isNotMasterError(err) {
192192
}
193193

194194
function isNodeShuttingDownError(err) {
195-
return SDAM_NODE_SHUTTING_DOWN_ERROR_CODES.has(err.code);
195+
return err.code && SDAM_NODE_SHUTTING_DOWN_ERROR_CODES.has(err.code);
196196
}
197197

198198
/**

test/functional/connections_stepdown_tests.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ const chai = require('chai');
44
const expect = chai.expect;
55

66
function ignoreNsNotFound(err) {
7-
if (!err.message.match(/ns not found/)) throw err;
7+
if (!err.message.match(/ns not found/)) {
8+
throw err;
9+
}
810
}
911

1012
function connectionCount(db) {

0 commit comments

Comments
 (0)