File tree Expand file tree Collapse file tree
test/integration/change-streams Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1168,6 +1168,12 @@ describe('Change Streams', function () {
11681168 } ) ;
11691169 } ) ;
11701170
1171+ // Note that `insertOne` in these tests is called with write concern `{ w: 'majority' }`.
1172+ // This is to avoid eventual consistency issues that make these tests brittle.
1173+ // A change stream won't see the new documents until they are persisted in the oplog and
1174+ // some MongoDB server versions (4.2-) used for testing default to write concern `{ w: 1 }`.
1175+ // Using write concern `{ w: 'majority' }` ensures that the new documents are persisted in
1176+ // the oplog when the `insertOne` promise resolves, making these tests more reliable.
11711177 describe ( '#bufferedCount()' , function ( ) {
11721178 it (
11731179 'should return 0 before starting to consume the change stream (empty collection)' ,
You can’t perform that action at this time.
0 commit comments