Skip to content

Commit aa4c832

Browse files
committed
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
1 parent 6e2565e commit aa4c832

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

lib/core/sdam/server.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,24 @@ class Server extends EventEmitter {
7272
// the server logger
7373
logger: Logger('Server', options),
7474
// the bson parser
75-
bson: options.bson || new BSON(),
75+
bson:
76+
options.bson ||
77+
new BSON([
78+
BSON.Binary,
79+
BSON.Code,
80+
BSON.DBRef,
81+
BSON.Decimal128,
82+
BSON.Double,
83+
BSON.Int32,
84+
BSON.Long,
85+
BSON.Map,
86+
BSON.MaxKey,
87+
BSON.MinKey,
88+
BSON.ObjectId,
89+
BSON.BSONRegExp,
90+
BSON.Symbol,
91+
BSON.Timestamp
92+
]),
7693
// client metadata for the initial handshake
7794
clientInfo: createClientInfo(options),
7895
// state variable to determine if there is an active server check in progress

lib/core/sdam/topology.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,24 @@ class Topology extends EventEmitter {
133133
// allow users to override the cursor factory
134134
Cursor: options.cursorFactory || CoreCursor,
135135
// the bson parser
136-
bson: options.bson || new BSON(),
136+
bson:
137+
options.bson ||
138+
new BSON([
139+
BSON.Binary,
140+
BSON.Code,
141+
BSON.DBRef,
142+
BSON.Decimal128,
143+
BSON.Double,
144+
BSON.Int32,
145+
BSON.Long,
146+
BSON.Map,
147+
BSON.MaxKey,
148+
BSON.MinKey,
149+
BSON.ObjectId,
150+
BSON.BSONRegExp,
151+
BSON.Symbol,
152+
BSON.Timestamp
153+
]),
137154
// a map of server instances to normalized addresses
138155
servers: new Map(),
139156
// Server Session Pool

0 commit comments

Comments
 (0)