This commit is contained in:
Jonasz Bigda
2023-03-25 21:51:42 +01:00
parent 0db1d5117e
commit b332e9ceb0
1044 changed files with 37502 additions and 63938 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;
}
@@ -438,7 +437,7 @@ function createChangeStreamCursor(self, options) {
if (self.pipeDestinations) {
const cursorStream = changeStreamCursor.stream(self.streamOptions);
for (let pipeDestination in self.pipeDestinations) {
for (let pipeDestination of self.pipeDestinations) {
cursorStream.pipe(pipeDestination);
}
}
@@ -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;