-
Type: Bug
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Change Streams
Node's change stream tryNext helper doesn't process change stream events (by calling the _processChange) helper, so the resume token for the change stream is not updated when a change is returned to the user. This has been the behavior since tryNext was implemented (https://github.com/mongodb/node-mongodb-native/commit/634ae4f93013c824bc153f132f0dd6c9bd2cc127).
This can cause a number of issues
- change streams aren't resumed properly if users are relying on `tryNext` in a loop
- change streams can produce duplicate change events
I believe this wasn't caught with existing tests for a few reasons:
- our change stream test coverage isn't exhaustive (there is no test for resumability that checks for duplicate resume events).
- our unified tests only test the `next` helper
- most importantly, the resumability tests only test resuming on a single change event after initializing the change stream. this is important because the `aggregate` call always sets the postBatchResumeToken if present, so a change stream that errors on the first change and resumes will resume properly and receive no duplicate events.
Acceptance Criteria
- make change stream's tryNext update the resume token while processing changes