Skip to content

Avoid unhandled errors in build streams #4009

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

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

asgerf
Copy link
Contributor

@asgerf asgerf commented Apr 22, 2025

The .pipe() method on Node.js streams have a gotcha in that they do not propagate errors downstream. This PR changes a few uses of .pipe() in our build scripts to the more modern stream.pipeline(), which propagates errors correctly.

Previously, if compilation failed with an error, the error would not be visible to Gulp because Gulp only sees the stream that writes to a file, not the intermediate 'esbuild' stream that generated the error. This resulted in unhelpful errors of the form:

[13:56:21] The following tasks did not complete: default, <series>, <parallel>, compileViewEsbuild
Did you forget to signal async completion?`

Now that the errors is propagated correctly, the TypeScript build error is surfaced correctly. In my concrete case this became the build error

[13:58:54] 'compileViewEsbuild' errored after 410 ms
[13:58:54] Error in plugin "gulp-esbuild"
Message:
    Build failed with 1 error:
src/view/compare-performance/ComparePerformance.tsx:24:27: ERROR: Could not resolve "crypto"

The .pipe() method on Node.js streams have a gotcha in that they
do not propagate errors downstream. In this case this meant that if
compilation failed with an error, it would not be visible to Gulp
because Gulp only sees the stream that writes to a file, not the
intermediate 'esbuild' stream that generated the error.

This changes a few uses of .pipe() to the more modern stream.pipeline(),
which propagates errors correctly.
@Copilot Copilot AI review requested due to automatic review settings April 22, 2025 11:59
@asgerf asgerf requested a review from a team as a code owner April 22, 2025 11:59
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates our build scripts to use the modern stream.pipeline() API instead of .pipe() so that errors from intermediate build streams are propagated correctly. Key changes include:

  • Replacing .pipe() chains with pipeline() calls in view.ts, typescript.ts, and textmate.ts.
  • Updating the import of pipeline from stream/promises for each file.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
extensions/ql-vscode/gulpfile.ts/view.ts Replaces .pipe() usage with pipeline() in compileViewEsbuild
extensions/ql-vscode/gulpfile.ts/typescript.ts Updates compileEsbuild to use pipeline() instead of chained .pipe()
extensions/ql-vscode/gulpfile.ts/textmate.ts Implements pipeline() in compileTextMateGrammar for proper error handling

Copy link
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@asgerf asgerf merged commit 1424307 into github:main Apr 22, 2025
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants