Skip to content

Commit

Permalink
listen for error events on change stream to avoid change stream tests…
Browse files Browse the repository at this point in the history
… flaking
  • Loading branch information
vkarpov15 committed Aug 21, 2024
1 parent 1b5fecc commit e0d5984
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/model.watch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ describe('model: watch: ', function() {
assert.strictEqual(readyCalled, false);

await close;
// Change stream may still emit "MongoAPIError: ChangeStream is closed" because change stream
// may still poll after close.
changeStream.on('error', () => {});
});

it('watch() close() closes the stream (gh-7022)', async function() {
Expand All @@ -75,6 +78,9 @@ describe('model: watch: ', function() {

const closedData = await closed;
assert.strictEqual(closedData, true);
// Change stream may still emit "MongoAPIError: ChangeStream is closed" because change stream
// may still poll after close.
changeStream.on('error', () => {});
});
});
});

0 comments on commit e0d5984

Please sign in to comment.