mongodb 3.3.1 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HISTORY.md +12 -0
- package/lib/change_stream.js +1 -2
- package/lib/core/sdam/topology.js +3 -3
- package/lib/gridfs-stream/download.js +12 -5
- package/lib/mongo_client.js +1 -1
- package/lib/operations/connect.js +1 -1
- package/lib/operations/execute_operation.js +28 -12
- package/lib/topologies/mongos.js +1 -1
- package/lib/topologies/replset.js +1 -1
- package/lib/topologies/server.js +1 -1
- package/lib/topologies/topology_base.js +4 -5
- package/package.json +1 -1
package/HISTORY.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
<a name="3.3.2"></a>
|
|
6
|
+
## [3.3.2](https://github.com/mongodb/node-mongodb-native/compare/v3.3.1...v3.3.2) (2019-08-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **change-stream:** default to server default batch size ([b3ae4c5](https://github.com/mongodb/node-mongodb-native/commit/b3ae4c5))
|
|
12
|
+
* **execute-operation:** return promise on session support check ([a976c14](https://github.com/mongodb/node-mongodb-native/commit/a976c14))
|
|
13
|
+
* **gridfs-stream:** ensure `close` is emitted after last chunk ([ae94cb9](https://github.com/mongodb/node-mongodb-native/commit/ae94cb9))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
5
17
|
<a name="3.3.1"></a>
|
|
6
18
|
## [3.3.1](https://github.com/mongodb/node-mongodb-native/compare/v3.3.0...v3.3.1) (2019-08-23)
|
|
7
19
|
|
package/lib/change_stream.js
CHANGED
|
@@ -367,10 +367,9 @@ function createChangeStreamCursor(self, options) {
|
|
|
367
367
|
|
|
368
368
|
const pipeline = [{ $changeStream: changeStreamStageOptions }].concat(self.pipeline);
|
|
369
369
|
const cursorOptions = applyKnownOptions({}, options, CURSOR_OPTIONS);
|
|
370
|
-
const changeStreamOptions = Object.assign({ batchSize: 1 }, options);
|
|
371
370
|
const changeStreamCursor = new ChangeStreamCursor(
|
|
372
371
|
self.topology,
|
|
373
|
-
new AggregateOperation(self.parent, pipeline,
|
|
372
|
+
new AggregateOperation(self.parent, pipeline, options),
|
|
374
373
|
cursorOptions
|
|
375
374
|
);
|
|
376
375
|
|
|
@@ -139,7 +139,7 @@ class Topology extends EventEmitter {
|
|
|
139
139
|
// Server Session Pool
|
|
140
140
|
sessionPool: null,
|
|
141
141
|
// Active client sessions
|
|
142
|
-
sessions:
|
|
142
|
+
sessions: new Set(),
|
|
143
143
|
// Promise library
|
|
144
144
|
promiseLibrary: options.promiseLibrary || Promise,
|
|
145
145
|
credentials: options.credentials,
|
|
@@ -421,10 +421,10 @@ class Topology extends EventEmitter {
|
|
|
421
421
|
startSession(options, clientOptions) {
|
|
422
422
|
const session = new ClientSession(this, this.s.sessionPool, options, clientOptions);
|
|
423
423
|
session.once('ended', () => {
|
|
424
|
-
this.s.sessions
|
|
424
|
+
this.s.sessions.delete(session);
|
|
425
425
|
});
|
|
426
426
|
|
|
427
|
-
this.s.sessions.
|
|
427
|
+
this.s.sessions.add(session);
|
|
428
428
|
return session;
|
|
429
429
|
}
|
|
430
430
|
|
|
@@ -185,12 +185,19 @@ function doRead(_this) {
|
|
|
185
185
|
}
|
|
186
186
|
if (!doc) {
|
|
187
187
|
_this.push(null);
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
|
|
189
|
+
process.nextTick(() => {
|
|
190
|
+
_this.s.cursor.close(function(error) {
|
|
191
|
+
if (error) {
|
|
192
|
+
__handleError(_this, error);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
_this.emit('close');
|
|
197
|
+
});
|
|
193
198
|
});
|
|
199
|
+
|
|
200
|
+
return;
|
|
194
201
|
}
|
|
195
202
|
|
|
196
203
|
var bytesRemaining = _this.s.file.length - _this.s.bytesRead;
|
package/lib/mongo_client.js
CHANGED
|
@@ -157,7 +157,7 @@ function MongoClient(url, options) {
|
|
|
157
157
|
options: options || {},
|
|
158
158
|
promiseLibrary: null,
|
|
159
159
|
dbCache: new Map(),
|
|
160
|
-
sessions:
|
|
160
|
+
sessions: new Set(),
|
|
161
161
|
writeConcern: WriteConcern.fromOptions(options),
|
|
162
162
|
namespace: new MongoDBNamespace('admin')
|
|
163
163
|
};
|
|
@@ -242,7 +242,7 @@ function collectEvents(mongoClient, topology) {
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
const emitDeprecationForNonUnifiedTopology = deprecate(() => {},
|
|
245
|
-
'current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. ' + 'To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to MongoClient.
|
|
245
|
+
'current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. ' + 'To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.');
|
|
246
246
|
|
|
247
247
|
function connect(mongoClient, url, options, callback) {
|
|
248
248
|
options = Object.assign({}, options);
|
|
@@ -35,18 +35,7 @@ function executeOperation(topology, operation, callback) {
|
|
|
35
35
|
!operation.hasAspect(Aspect.SKIP_SESSION) &&
|
|
36
36
|
topology.shouldCheckForSessionSupport()
|
|
37
37
|
) {
|
|
38
|
-
|
|
39
|
-
// should go away when we drop legacy topology types.
|
|
40
|
-
topology.selectServer(ReadPreference.primaryPreferred, err => {
|
|
41
|
-
if (err) {
|
|
42
|
-
callback(err);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
executeOperation(topology, operation, callback);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
return;
|
|
38
|
+
return selectServerForSessionSupport(topology, operation, callback);
|
|
50
39
|
}
|
|
51
40
|
|
|
52
41
|
const Promise = topology.s.promiseLibrary;
|
|
@@ -179,4 +168,31 @@ function executeWithServerSelection(topology, operation, callback) {
|
|
|
179
168
|
});
|
|
180
169
|
}
|
|
181
170
|
|
|
171
|
+
// TODO: This is only supported for unified topology, it should go away once
|
|
172
|
+
// we remove support for legacy topology types.
|
|
173
|
+
function selectServerForSessionSupport(topology, operation, callback) {
|
|
174
|
+
const Promise = topology.s.promiseLibrary;
|
|
175
|
+
|
|
176
|
+
let result;
|
|
177
|
+
if (typeof callback !== 'function') {
|
|
178
|
+
result = new Promise((resolve, reject) => {
|
|
179
|
+
callback = (err, result) => {
|
|
180
|
+
if (err) return reject(err);
|
|
181
|
+
resolve(result);
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
topology.selectServer(ReadPreference.primaryPreferred, err => {
|
|
187
|
+
if (err) {
|
|
188
|
+
callback(err);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
executeOperation(topology, operation, callback);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
|
|
182
198
|
module.exports = executeOperation;
|
package/lib/topologies/mongos.js
CHANGED
package/lib/topologies/server.js
CHANGED
|
@@ -291,11 +291,12 @@ class TopologyBase extends EventEmitter {
|
|
|
291
291
|
|
|
292
292
|
startSession(options, clientOptions) {
|
|
293
293
|
const session = new ClientSession(this, this.s.sessionPool, options, clientOptions);
|
|
294
|
+
|
|
294
295
|
session.once('ended', () => {
|
|
295
|
-
this.s.sessions
|
|
296
|
+
this.s.sessions.delete(session);
|
|
296
297
|
});
|
|
297
298
|
|
|
298
|
-
this.s.sessions.
|
|
299
|
+
this.s.sessions.add(session);
|
|
299
300
|
return session;
|
|
300
301
|
}
|
|
301
302
|
|
|
@@ -382,9 +383,7 @@ class TopologyBase extends EventEmitter {
|
|
|
382
383
|
close(forceClosed, callback) {
|
|
383
384
|
// If we have sessions, we want to individually move them to the session pool,
|
|
384
385
|
// and then send a single endSessions call.
|
|
385
|
-
|
|
386
|
-
this.s.sessions.forEach(session => session.endSession());
|
|
387
|
-
}
|
|
386
|
+
this.s.sessions.forEach(session => session.endSession());
|
|
388
387
|
|
|
389
388
|
if (this.s.sessionPool) {
|
|
390
389
|
this.s.sessionPool.endAllPooledSessions();
|