File tree 2 files changed +11
-4
lines changed
test/integration/change-streams
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -636,7 +636,9 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
636
636
}
637
637
638
638
/**
639
- * Cleans up client-side resources used by the MongoCLient and . This includes:
639
+ * Cleans up client-side resources used by the MongoClient.
640
+ *
641
+ * This includes:
640
642
*
641
643
* - Closes all open, unused connections (see note).
642
644
* - Ends all in-use sessions with {@link ClientSession#endSession|ClientSession.endSession()}.
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ describe('Change Streams', function () {
63
63
await csDb . createCollection ( 'test' ) . catch ( ( ) => null ) ;
64
64
collection = csDb . collection ( 'test' ) ;
65
65
changeStream = collection . watch ( ) ;
66
+ changeStream . on ( 'error' , ( ) => null ) ;
66
67
} ) ;
67
68
68
69
afterEach ( async ( ) => {
@@ -702,15 +703,19 @@ describe('Change Streams', function () {
702
703
703
704
const outStream = new PassThrough ( { objectMode : true } ) ;
704
705
705
- // @ts -expect-error: transform requires a Document return type
706
- changeStream . stream ( { transform : JSON . stringify } ) . pipe ( outStream ) ;
706
+ const transform = doc => ( { doc : JSON . stringify ( doc ) } ) ;
707
+ changeStream
708
+ . stream ( { transform } )
709
+ . on ( 'error' , ( ) => null )
710
+ . pipe ( outStream )
711
+ . on ( 'error' , ( ) => null ) ;
707
712
708
713
const willBeData = once ( outStream , 'data' ) ;
709
714
710
715
await collection . insertMany ( [ { a : 1 } ] ) ;
711
716
712
717
const [ data ] = await willBeData ;
713
- const parsedEvent = JSON . parse ( data ) ;
718
+ const parsedEvent = JSON . parse ( data . doc ) ;
714
719
expect ( parsedEvent ) . to . have . nested . property ( 'fullDocument.a' , 1 ) ;
715
720
716
721
outStream . destroy ( ) ;
You can’t perform that action at this time.
0 commit comments