On this page
trueif the cursor is closed and there are no remaining objects in the batch.
Consider the following
while loop iterating through updates to a
change stream cursor:
A change stream cursor can return an empty batch if no new data changes have occured within a set period of time. This causes the while loop to exit prematurely as
false when it detects the empty batch. However, the change stream cursor is still open and able to return more documents in the future.
cursor.isExhausted() to ensure the while loop only exits when the cursor is closed and there are no documents remaining in the batch: