From dbfe4f5cd9231f3d9749cc44c1f0a471eb7a9880 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Thu, 22 Aug 2019 12:12:04 -0400 Subject: [PATCH] refactor: check err.code exists before checking if its in a set --- lib/core/error.js | 2 +- test/functional/connections_stepdown_tests.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/core/error.js b/lib/core/error.js index 0aebb093eb..757c26229a 100644 --- a/lib/core/error.js +++ b/lib/core/error.js @@ -192,7 +192,7 @@ function isNotMasterError(err) { } function isNodeShuttingDownError(err) { - return SDAM_NODE_SHUTTING_DOWN_ERROR_CODES.has(err.code); + return err.code && SDAM_NODE_SHUTTING_DOWN_ERROR_CODES.has(err.code); } /** diff --git a/test/functional/connections_stepdown_tests.js b/test/functional/connections_stepdown_tests.js index 0ef0c1d0a2..f167c0521a 100644 --- a/test/functional/connections_stepdown_tests.js +++ b/test/functional/connections_stepdown_tests.js @@ -4,7 +4,9 @@ const chai = require('chai'); const expect = chai.expect; function ignoreNsNotFound(err) { - if (!err.message.match(/ns not found/)) throw err; + if (!err.message.match(/ns not found/)) { + throw err; + } } function connectionCount(db) {