-
Type: Bug
-
Resolution: Gone away
-
Priority: Major - P3
-
None
-
Affects Version/s: 6.8.0
-
Component/s: Change Streams, TypeScript
Use Case
As a developer
I want use the change stream without receiving type errors
So that it works like 6.7.0
Repro code
const resumeToken = get_the_resume_token() const changeStream = collection.watch( [ ...the pipeline does a $match and a $project ], { fullDocument: 'updateLookup', resumeToken // NOTE: in our scenario this is undefined! } ) changeStream.on('change', changeStreamChangeEventHandler) changeStream.on('error', async(error) => { log.error({ error, code: error?.code }, 'changeStream error') // here we see the TypeError throw new Error('unexpected error, restart service') // we decide to crash on error (there is actually more logic to it but it would not be interesting for this repro. })
The log seen in the `error` handler is the following:
{ "level": 50, "time": 1719911469235, "pid": 6, "hostname": "tenant-overview-84d6f88f57-62g6h", "error": { "type": "TypeError", "message": "(responseType ?? responses_1.MongoDBResponse).make is not a function", "stack": "TypeError: (responseType ?? responses_1.MongoDBResponse).make is not a function at Connection.sendWire (/home/node/app/node_modules/mongodb/lib/cmap/connection.js:243:80) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Connection.sendCommand (/home/node/app/node_modules/mongodb/lib/cmap/connection.js:280:24) at async Connection.command (/home/node/app/node_modules/mongodb/lib/cmap/connection.js:313:26) at async Server.command (/home/node/app/node_modules/mongodb/lib/sdam/server.js:167:29) at async AggregateOperation.executeCommand (/home/node/app/node_modules/mongodb/lib/operations/command.js:73:16) at async AggregateOperation.execute (/home/node/app/node_modules/mongodb/lib/operations/aggregate.js:86:16) at async executeOperation (/home/node/app/node_modules/mongodb/lib/operations/execute_operation.js:136:16) at async ChangeStreamCursor._initialize (/home/node/app/node_modules/mongodb/lib/cursor/change_stream_cursor.js:81:26) at async ChangeStreamCursor.cursorInit (/home/node/app/node_modules/mongodb/lib/cursor/abstract_cursor.js:471:27)" }, "msg": "changeStream error" }
The affected line causes the make is not a function TypeError
responseType ?? responses_1.MongoDBResponse).make is not a function
My guess is that we are either incurring in a falsy (but not nullish) responseType OR an unexpected responseType that doesn't fit the MongoDBResponseConstructor type.
I couldn't do further debugging on my own.
User Impact
- At the moment we can't upgrade the driver without incurring in this issue, rolling back to v6.7.0 makes the application work.
Dependencies
none
Unknowns
- How to properly debug/test this issue to submit a PR on my own, I think I've figured out what is going on and have a possible proposal but I can't be sure.
Acceptance Criteria
Implementation Requirements
none
Testing Requirements
none
Documentation Requirements
none
Follow Up Requirements
none
- is related to
-
DRIVERS-719 Client Side Support for OpenTelemetry
- Defining