nodejs / readable-stream

Node-core streams for userland
https://nodejs.org/api/stream.html
Other
1.03k stars 225 forks source link

Is `ERR_MULTIPLE_CALLBACK` missing a `new`? #532

Open Jarred-Sumner opened 6 months ago

Jarred-Sumner commented 6 months ago

ERR_MULTIPLE_CALLBACK is an Error subclass (eventually) defined here:

https://github.com/nodejs/readable-stream/blob/a2e9aedf4aeee4a5e4d8efcb175edb67e2817eaa/lib/ours/errors.js#L70-L97

In this line, ERR_MULTIPLE_CALLBACK is called instead of constructed:

https://github.com/nodejs/readable-stream/blob/a2e9aedf4aeee4a5e4d8efcb175edb67e2817eaa/lib/internal/streams/writable.js#L594

I ran into this in a difficult to isolate scenario

image

vweevers commented 6 months ago

Looks like a bug in Node.js: https://github.com/nodejs/node/blob/10c6596f6d7abf7451112e767f8277fcd276d796/lib/internal/streams/writable.js#L879

mcollina commented 6 months ago

@Jarred-Sumner would you like to send a PR? We can't do much about the Node.js source, and we should adapt the code in ours/errors.js to be spawned without new.

A test to repro this would be nice.

vweevers commented 5 months ago

https://github.com/nodejs/node/pull/52110