From da1f2906d924c26b24c4692d3b3f5270cbbded93 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, 10 insertions(+), 1 deletion(-) 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 5d7588379..c25e622ed 100644 --- a/source/monitoring-and-logging/change-streams.txt +++ b/source/monitoring-and-logging/change-streams.txt @@ -44,6 +44,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: @@ -72,6 +74,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 @@ -98,7 +101,7 @@ read events from the change stream: changeStream.close(); -.. include:: /includes/changestream-paradigm-warning.rst +.. _node-usage-watch: Examples --------