From aa4c832489decee0cd47a6a61a6b72cebc35b987 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Wed, 9 Oct 2019 17:53:59 -0400 Subject: [PATCH] fix(topology): include all BSON types in ctor for bson-ext support bson-ext requires a reference to all the BSON types in the constructor in order to be able to call back into JavaScript during serialization/deserialization. NODE-2092 --- lib/core/sdam/server.js | 19 ++++++++++++++++++- lib/core/sdam/topology.js | 19 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/core/sdam/server.js b/lib/core/sdam/server.js index 1c8d788a10..2b76c70e80 100644 --- a/lib/core/sdam/server.js +++ b/lib/core/sdam/server.js @@ -72,7 +72,24 @@ class Server extends EventEmitter { // the server logger logger: Logger('Server', options), // the bson parser - bson: options.bson || new BSON(), + bson: + options.bson || + new BSON([ + BSON.Binary, + BSON.Code, + BSON.DBRef, + BSON.Decimal128, + BSON.Double, + BSON.Int32, + BSON.Long, + BSON.Map, + BSON.MaxKey, + BSON.MinKey, + BSON.ObjectId, + BSON.BSONRegExp, + BSON.Symbol, + BSON.Timestamp + ]), // client metadata for the initial handshake clientInfo: createClientInfo(options), // state variable to determine if there is an active server check in progress diff --git a/lib/core/sdam/topology.js b/lib/core/sdam/topology.js index c644d30ff4..f7d0fa2174 100644 --- a/lib/core/sdam/topology.js +++ b/lib/core/sdam/topology.js @@ -133,7 +133,24 @@ class Topology extends EventEmitter { // allow users to override the cursor factory Cursor: options.cursorFactory || CoreCursor, // the bson parser - bson: options.bson || new BSON(), + bson: + options.bson || + new BSON([ + BSON.Binary, + BSON.Code, + BSON.DBRef, + BSON.Decimal128, + BSON.Double, + BSON.Int32, + BSON.Long, + BSON.Map, + BSON.MaxKey, + BSON.MinKey, + BSON.ObjectId, + BSON.BSONRegExp, + BSON.Symbol, + BSON.Timestamp + ]), // a map of server instances to normalized addresses servers: new Map(), // Server Session Pool