Skip to content

DOCSP-51959 Add a warning about tryNext bug to all change stream manual iteration examples #1189

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

Merged
merged 4 commits into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions source/includes/try-next-warning.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. warning::

The `tryNext() <{+api+}/classes/ChangeStream.html#tryNext>`_ method does not
automatically update the change stream's `resumeToken.
<{+api+}/classes/ChangeStream.html#resumeToken>`_ If you require an updated
``resumeToken``, use the ``next()`` method.
5 changes: 3 additions & 2 deletions source/monitoring-and-logging/change-streams.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ section for more information on the settings you can configure with this object.
The ``watch()`` method returns an instance of a `ChangeStream <{+api+}/classes/ChangeStream.html>`__. You can read events from
change streams by iterating over them or listening for events.

.. include:: /includes/changestream-paradigm-warning.rst

Select the tab that corresponds to the way you want to
read events from the change stream:

Expand Down Expand Up @@ -88,6 +90,7 @@ read events from the change stream:
- ``next()`` to request the next document in the stream
- ``close()`` to close the ChangeStream

.. include:: /includes/try-next-warning.rst
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a warning below the tabs section on line 117/118 (not this one, but I can't comment directly on it), that I would move into the other tabs, because:

  • I don't think it's only relevant to the Idiomatic Iteration and Event tabs (ask tech review to confirm)
  • It looks a little odd to have two warnings appear in a row

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe Iterator mode applies to idomatic and manual iteration, but I will double check as I agree stacking callouts is odd.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is relevant to all tabs because it's a warning not to mix the modes defined in each tab, basically.

What do y'all think of moving this above the section altogether?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that, under where it says "read events from change streams by iterating over them or listening for events." The warning can emphasize the or.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that works nicely. Thanks


.. tab::
:tabid: Event
Expand All @@ -114,8 +117,6 @@ read events from the change stream:

changeStream.close();

.. include:: /includes/changestream-paradigm-warning.rst

.. _node-usage-watch:

Examples
Expand Down
Loading