-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
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.
Use Case
As a... user of the tryNext api
I want... resume tokens to be updated correctly on change events
So that... I can resume the change stream from the correct point in time
User Experience
- See NODE-7042
Dependencies
- N/A
Risks/Unknowns
- What could go wrong while implementing this change? (e.g., performance, inadvertent behavioral changes in adjacent functionality, existing tech debt, etc)
- Is there an opportunity for better cross-driver alignment or testing in this area?
- Is there an opportunity to improve existing documentation on this subject?
Acceptance Criteria
Implementation Requirements
- make change stream's tryNext update the resume token while processing changes
Testing Requirements
- unit test, spec test sync, etc
Documentation Requirements
- N/A
Follow Up Requirements
- N/A
- is depended on by
-
NODE-7042 ChangeStream resumeToken not correctly updated when using tryNext()
-
- Blocked
-