Gulp v5 中未正确处理管道错误
在打开此问题之前,请完成以下任务: * [x] 使用页面顶部的搜索栏搜索此仓库中已打开的类似问题或讨论。 * [ ] 如果您正在寻求 gulp 团队或社区的帮助,请打开 讨论。 * [ ] 如果您认为使用的插件存在问题,请打开 讨论。 * [x] 如果您认为我们的代码中存在 bug,请打开此问题。 ### 您期望发生什么情况? 使用 gulp.src(...).pipe(stream).pipe(secondStream) 时,任何 stream 错误都应由 Gulp 显示并完成任务(将其标记为失败)。 ### 实际发生了什么? 流程中的 stream 错误未被 Gulp 显示,且任务被显示为未完成。 ### 请提供您的 gulpfile 示例 ### gulpfile.js 导入 gulp 和 Transform 和 PassThrough 从 node:stream 导入 export default () => gulp src('./gulpfile.js') .pipe(new Transform({ transform(file, encoding, done) { done(new Error('example')) }, objectMode: true })).pipe(new PassThrough({ objectMode: true })) 终端输出 / 屏幕截图 在 Gulp v5 中: $ gulp [01:46:48] 使用 gulpfile ~/Desktop/gulpfile.js [01:46:48] 正在启动 'default'... [01:46:48] 以下任务未完成: default 您是否忘记了发出异步完成信号? 在 Gulp v4 中,此操作正确地工作: $ gulp [01:45:39] 使用 gulpfile ~/Desktop/gulpfile.js [01:45:39] 正在启动 'default'... [01:45:39] 'default' 在 15 毫秒后出错 [01:45:39] 错误: example [01:45:39] 在 Transform.transform [as _transform] (file:///.../Desktop/gulpfile.js:8:12) 处 [01:45:39] 在 Transform._write (node:internal/streams/transform:171:8) 处 [01:45:39] 在 writeOrBuffer (node:internal/streams/writable:564:12) 处 [01:45:39] 在 _write (node:internal/streams/writable:493:10) 处 [01:45:39] 在 Writable.write (node:internal/streams/writable:502:10) 处 [01:45:39] 在 DestroyableTransform.ondata (/.../Desktop/node_modules/to-through/node_modules/readable-stream/lib/_stream_readable.js:619:20) 处 [01:45:39] 在 DestroyableTransform.emit (node:events:520:28) 处 [01:45:39] 在 DestroyableTransform.emit (node:domain:551:15) 处 [01:45:39] 在 addChunk (/.../Desktop/node_modules/to-through/node_modules/readable-stream/lib/_stream_readable.js:291:12) 处 [01:45:39] 在 readableAddChunk (/.../Desktop/node_modules/to-through/node_modules/readable-stream/lib/_stream_readable.js:278:11) 处 ### 请提供以下信息: * 操作系统和版本 [例如 MacOS Catalina 10.15.4]: Ubuntu 24.04 * node 版本(运行 node -v): 22.3.0 * npm 版本(运行 npm -v): 10.8.1 * gulp 版本(运行 gulp -v): 5.0.0 ### 补充信息 此错误仅在出错的流不是流程中的最后一行时发生。这意味着必须多次调用 .pipe()。 似乎这个错误与 vinyl-fs(https://GitHub.com/gulpjs/vinyl-fs/pull/333 by @sttk) 和to-through` 有关…
内容来源: gulpjs/gulp