-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(NODE-4763): tryNext not updating resumeToken for a returned update #4587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(NODE-4763): tryNext not updating resumeToken for a returned update #4587
Conversation
Hi @Omnicpie, thanks for the submission. Your right - this fix will need testing. We likely needs tests to confirm that the tryNext() correctly updates the resume token both when there is a document and there is not a document, for both the inital change stream aggregates and subsequent getMores. We have a lot of change stream tests in change_stream.test.ts - if you look at the tests in that file, that should help get you going in the right direction!
Also note that _processChange
throws an error if the change is null
. So we should only call it if there actually was a change from cursor.tryNext()
.
Fixed in #4636
Description
This PR attempts to fix an issue noticed when using
tryNext
in which it does not correctly update the resumeToken when updates are received, meaning that if the change stream is resumed it can end up resuming in the past, causing issues.What is changing?
The change is small and involves changing the
tryNext
function to use the internal_processChange
function which handles updating the resume token before returning the given change. This is used bynext
already, so seems to be a good solution overall.What is the motivation for this change?
To prevent issues where resuming the change-stream using
tryNext
causes the client to go backwards in time, potentially causing issues on systems that use this functionalityNOTE FOR REVIEWERS
I wasn't sure where to add test coverage for this, or what exactly I should call in terms of testing, Happy to add some tests for this functionality if someone can point me in the right direction of the "where and how" to test this.
Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript