fix(NODE-4763): tryNext not updating resumeToken for a returned update #4587
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR attempts to fix an issue noticed when using
tryNextin 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
tryNextfunction to use the internal_processChangefunction which handles updating the resume token before returning the given change. This is used bynextalready, so seems to be a good solution overall.What is the motivation for this change?
To prevent issues where resuming the change-stream using
tryNextcauses 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:lintscripttype(NODE-xxxx)[!]: descriptionfeat(NODE-1234)!: rewriting everything in coffeescript