-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Pipeline errors are not properly handled in Gulp v5 #2812
Comments
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
I've also noticed that issue with 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 streamx.Transform({transform(chunk, done) { ... }) |
I did some additional digging. Background problemIn Node.js, Node.js introduced the So, actually, users should not do: export default () => gulp.src(...)
.pipe(...)
.pipe(...)
.pipe(...) But: export default () => pipeline(
gulp.src(...),
...,
...,
...,
) Or maybe: export default () => gulp.src(...)
.pipe(...)
.compose(...)
.compose(...) Gulp v4 workaroundUnfortunately, the former pattern is documented everywhere by Gulp, and used by virtually all Gulp users. If any stream in the pipeline (except the last one) errors, this raises an uncaught exception at the process level. Gulp 4 used to work around that by handling uncaught exceptions. It does this using Gulp v5 bugGulp v5 switched from using I filed an issue mafintosh/streamx#94 and created a PR at mafintosh/streamx#95. If that PR is merged and released in a patch or minor release, Gulp should automatically get the fix, which would solve this issue. |
Also note https://github.com/orgs/gulpjs/discussions/2586 Do you have an idea as to why the through2 continues to work, but not node:stream? |
My PR on To me, it seems like the real problem is the switch to But I understand that Gulp will probably not switch away from |
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
(gulpjs/vinyl-fs#333 by @sttk) andto-through
(gulpjs/to-through#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
What seems to be happening is:
stream.destroy(error)
stream.emit('error', error)
error
event is not properly triggered ondomain
, which meansasync-done
never completes.The text was updated successfully, but these errors were encountered: