Open ehmicky opened 2 months ago
However, it does not remove the error event listener.
Would that mean the problem is with streamx and not gulp? If I understood the flow correctly, streamx wraps original 'object' stream with itself. Looking at this part https://github.com/mafintosh/streamx/blob/625ce37f624aa51cda95fa1bffdc3fae2ecd03a5/index.js#L267-L277
isStreamx(...)
is obviously false for node:stream
Transform obj, so the 2nd branch is used. Should it instead use the 1st one? Or, some other event setup entirely
I've also noticed that issue with node:stream
. However, gulpfile with through2 does seem to work correctly
through2.obj((chunk, enc, done) => { ... }) // original 'readable-stream' object is returned, things seem to work ok
Replacing the above with streamx also finishes the task and shows the error (minor issue having tsc warning about a type mismatch)
streamx.Transform({transform(chunk, done) { ... })
Before you open this issue, please complete the following tasks:
What were you expecting to happen?
When using
gulp.src(...).pipe(stream).pipe(secondStream)
, anystream
error should be shown by Gulp and complete the task (marking it as failed).What actually happened?
stream
errors in the pipeline are not shown by Gulp, and the task is shown as incomplete.Please give us a sample of your gulpfile
Terminal output / screenshots
With Gulp v5:
With Gulp v4, this worked correctly:
Please provide the following information:
node -v
): 22.3.0npm -v
): 10.8.1gulp -v
): 5.0.0Additional information
This bug only happens when the stream that errors is not the last line in the pipeline. This means
.pipe()
must be called more than once.It seems like this bug is related to
vinyl-fs
(https://github.com/gulpjs/vinyl-fs/pull/333 by @sttk) andto-through
(https://github.com/gulpjs/to-through/pull/9 by @coreyfarrell) switching tostreamx
. The problem seems to be happening insideasync-done
, specifically the following line:https://github.com/gulpjs/async-done/blob/4a7efae92c90ae6358412f2dc759561f0cb94ccc/index.js#L31
The
error
event is not properly triggered ondomain
, which meansasync-done
never completes.Looking at the Node.js source code:
domain.once('error')
is triggered in Node.js here: https://github.com/nodejs/node/blob/eb54c54bf5f7c077ec094d27cc1d93cd318bde06/lib/domain.js#L539error
event listener: https://github.com/nodejs/node/blob/eb54c54bf5f7c077ec094d27cc1d93cd318bde06/lib/domain.js#L481What seems to be happening is:
stream.destroy(error)
stream.emit('error', error)
Then, in Gulp v4:
.pipe()
logic fromreadable-stream
catches theerror
event, removes the event listener then callsstream.emit('error', error)
again, here: https://github.com/nodejs/readable-stream/blob/c85db76d4c41f64fd082c9263c3a918bec6f38a0/lib/_stream_readable.js#L640.error
event listeners,domain.once('error')
is properly triggered.async-done
completing properly.However, in Gulp v5:
.pipe()
logic fromstreamx
does something similar: https://github.com/mafintosh/streamx/blob/625ce37f624aa51cda95fa1bffdc3fae2ecd03a5/index.js#L274 and https://github.com/mafintosh/streamx/blob/625ce37f624aa51cda95fa1bffdc3fae2ecd03a5/index.js#L443error
event listener.domain.once('error')
is not triggered due to https://github.com/nodejs/node/blob/eb54c54bf5f7c077ec094d27cc1d93cd318bde06/lib/domain.js#L481async-done
does not complete, and Gulp shows the task as incomplete.