@@ -395,6 +395,25 @@ describe('Change Streams', function () {
395
395
expect ( change ) . to . have . property ( '_id' ) . that . deep . equals ( changeStream . resumeToken ) ;
396
396
}
397
397
} ) ;
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
+ } ) ;
398
417
} ) ;
399
418
400
419
it ( 'should cache using event listener form' , {
@@ -1847,6 +1866,8 @@ describe('Change Streams', function () {
1847
1866
1848
1867
changeStream = collection . watch ( [ ] ) ;
1849
1868
1869
+ // Configure a fail point with skip: 1 to simulate a server failure on the second `getMore`,
1870
+ // triggering the resume process.
1850
1871
await client . db ( 'admin' ) . command ( {
1851
1872
configureFailPoint : is4_2Server ( this . configuration . version )
1852
1873
? 'failCommand'
0 commit comments