@@ -34,31 +34,37 @@ const NO_RESUME_TOKEN_ERROR =
3434 'A change stream document has been received that lacks a resume token (_id).' ;
3535const CHANGESTREAM_CLOSED_ERROR = 'ChangeStream is closed' ;
3636
37- const INVALID_STAGE_OPTIONS = [
38- 'raw' ,
39- 'useBigInt64' ,
37+ const INVALID_STAGE_OPTIONS = new Set ( [
38+ 'authdb' ,
39+ 'batchSize' ,
40+ 'bsonRegExp' ,
41+ 'collation' ,
42+ 'comment' ,
43+ 'dbName' ,
44+ 'enableUtf8Validation' ,
45+ 'fieldsAsRaw' ,
46+ 'ignoreUndefined' ,
47+ 'maxAwaitTimeMS' ,
48+ 'maxTimeMS' ,
49+ 'promoteBuffers' ,
4050 'promoteLongs' ,
4151 'promoteValues' ,
42- 'promoteBuffers ' ,
43- 'ignoreUndefined ' ,
44- 'bsonRegExp ' ,
52+ 'raw ' ,
53+ 'rawData ' ,
54+ 'readPreference ' ,
4555 'serializeFunctions' ,
46- 'fieldsAsRaw' ,
47- 'enableUtf8Validation' ,
56+ 'timeoutContext' ,
4857 'timeoutMS' ,
49- 'readPreference '
50- ] ;
58+ 'useBigInt64 '
59+ ] ) ;
5160
52- export function filterOutOptions ( options : AnyOptions , names : ReadonlyArray < string > ) : AnyOptions {
61+ export function filterOutOptions ( options : AnyOptions ) : AnyOptions {
5362 const filterOptions : AnyOptions = { } ;
54-
5563 for ( const name in options ) {
56- if ( ! names . includes ( name ) ) {
64+ if ( ! INVALID_STAGE_OPTIONS . has ( name ) ) {
5765 filterOptions [ name ] = options [ name ] ;
5866 }
5967 }
60-
61- // Filtered options
6268 return filterOptions ;
6369}
6470
@@ -919,7 +925,7 @@ export class ChangeStream<
919925 private _createChangeStreamCursor (
920926 options : ChangeStreamOptions | ChangeStreamCursorOptions
921927 ) : ChangeStreamCursor < TSchema , TChange > {
922- const changeStreamStageOptions : Document = filterOutOptions ( options , INVALID_STAGE_OPTIONS ) ;
928+ const changeStreamStageOptions : Document = filterOutOptions ( options ) ;
923929 if ( this . type === CHANGE_DOMAIN_TYPES . CLUSTER ) {
924930 changeStreamStageOptions . allChangesForCluster = true ;
925931 }
0 commit comments