From 04153d26b6c3496a087becc2909807973a183e17 Mon Sep 17 00:00:00 2001 From: Melanie Ballard Date: Thu, 17 Jul 2025 16:01:27 -0400 Subject: [PATCH] DOCSP-51959 Add a warning about tryNext bug to all change stream manual iteration examples (#1189) * DOCSP-51959 tryNext resumeToken error warning * fix link * bracket removal * move warning (cherry picked from commit 7baddf7893a2ba28b08cb6af232d29af0eb6370a) --- source/includes/try-next-warning.rst | 6 ++++++ source/monitoring-and-logging/change-streams.txt | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 source/includes/try-next-warning.rst diff --git a/source/includes/try-next-warning.rst b/source/includes/try-next-warning.rst new file mode 100644 index 000000000..800ba355e --- /dev/null +++ b/source/includes/try-next-warning.rst @@ -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. \ No newline at end of file diff --git a/source/monitoring-and-logging/change-streams.txt b/source/monitoring-and-logging/change-streams.txt index d0c573eb0..8bf724333 100644 --- a/source/monitoring-and-logging/change-streams.txt +++ b/source/monitoring-and-logging/change-streams.txt @@ -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: @@ -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 .. tab:: :tabid: Event @@ -114,8 +117,6 @@ read events from the change stream: changeStream.close(); -.. include:: /includes/changestream-paradigm-warning.rst - .. _node-usage-watch: Examples