@@ -395,6 +395,25 @@ describe('Change Streams', function () {
395395 expect ( change ) . to . have . property ( '_id' ) . that . deep . equals ( changeStream . resumeToken ) ;
396396 }
397397 } ) ;
398+
399+ it ( 'should cache the resume token on an actual change, not on a probe' , {
400+ metadata : { requires : { topology : 'replicaset' } } ,
401+ async test ( ) {
402+ await initIteratorMode ( changeStream ) ;
403+ const resumeToken = changeStream . resumeToken ;
404+
405+ await collection . insertOne ( { a : 1 } ) ;
406+
407+ const hasNext = await changeStream . hasNext ( ) ;
408+ expect ( hasNext ) . to . be . true ;
409+
410+ expect ( changeStream . resumeToken ) . to . equal ( resumeToken ) ;
411+
412+ const change = await changeStream . next ( ) ;
413+ expect ( change ) . to . have . property ( '_id' ) . that . deep . equals ( changeStream . resumeToken ) ;
414+ expect ( resumeToken ) . to . not . equal ( changeStream . resumeToken ) ;
415+ }
416+ } ) ;
398417 } ) ;
399418
400419 it ( 'should cache using event listener form' , {
@@ -1847,6 +1866,8 @@ describe('Change Streams', function () {
18471866
18481867 changeStream = collection . watch ( [ ] ) ;
18491868
1869+ // Configure a fail point with skip: 1 to simulate a server failure on the second `getMore`,
1870+ // triggering the resume process.
18501871 await client . db ( 'admin' ) . command ( {
18511872 configureFailPoint : is4_2Server ( this . configuration . version )
18521873 ? 'failCommand'
0 commit comments