Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4763

changestream tryNext should update the resume token when return a change

      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

            Assignee:
            Unassigned Unassigned
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: