This commit is contained in:
2020-08-20 11:44:32 +02:00
parent 4715fc1814
commit 6aceefeb2f
2891 changed files with 11239 additions and 347539 deletions

View File

@@ -169,7 +169,6 @@ class ChangeStream extends EventEmitter {
/**
* Is the change stream closed
* @method ChangeStream.prototype.isClosed
* @param {boolean} [checkCursor=true] also check if the underlying cursor is closed
* @return {boolean}
*/
isClosed() {
@@ -326,8 +325,8 @@ class ChangeStreamCursor extends Cursor {
_initializeCursor(callback) {
super._initializeCursor((err, result) => {
if (err) {
callback(err);
if (err || result == null) {
callback(err, result);
return;
}
@@ -483,6 +482,11 @@ function waitForTopologyConnected(topology, options, callback) {
function processNewChange(changeStream, change, callback) {
const cursor = changeStream.cursor;
// a null change means the cursor has been notified, implicitly closing the change stream
if (change == null) {
changeStream.closed = true;
}
if (changeStream.closed) {
if (callback) callback(new MongoError('ChangeStream is closed'));
return;