-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(NODE-5901): propagate errors to transformed stream in cursor #3985
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vkarpov15 - could we also add a test reproducing the behaviour? Maybe could go in https://github.com/mongodb/node-mongodb-native/blob/main/test/integration/crud/crud_api.test.ts
@durran sorry, I forgot you had a specific file in your comment, and ended up adding the test to |
Yeah that's fine as well. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ty @vkarpov15! LGTM
Description
Right now, any query error when using cursor
stream()
withtransform
option leads to an uncatchable error. Consider the following script: the following script throws an uncaught "Sort exceeded memory limit" even though there's anon('error')
handler.What is changing?
Propagate errors from query stream to transformed stream
Is there new documentation needed for these changes?
No
What is the motivation for this change?
Because the original query stream isn't returned when you set
transform
option, there's no way to catch errors that occur.Some more reading here. In theory, we could use Node's new
stream.pipeline()
function for this, but TypeScript complains aboutstream.pipeline([readable, transformedStream])
.Release Highlight
Errors on cursor transform streams are now properly propagated.
These were previously swallowed and now will be emitted on the
error
event:Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript