fix: reject with error from parent context on close#102
Merged
lukekarrys merged 3 commits intomainfrom Apr 15, 2024
Merged
Conversation
wraithgar
reviewed
Apr 15, 2024
wraithgar
approved these changes
Apr 15, 2024
Member
|
Everything looks good here, I get why we're doing it, but it still makes me nervous in light of things like npm/run-script#188. Let's be extra wary of new issues we didn't expect. |
Closed
Merged
lukekarrys
pushed a commit
that referenced
this pull request
May 4, 2024
🤖 I have created a release *beep* *boop* --- ## [7.0.2](v7.0.1...v7.0.2) (2024-05-04) ### Bug Fixes * [`4912015`](4912015) [#102](#102) reject with error from parent context on close (#102) (@lukekarrys) ### Chores * [`09872d7`](09872d7) [#105](#105) linting: no-unused-vars (@lukekarrys) * [`70f0eb7`](70f0eb7) [#105](#105) bump @npmcli/template-oss to 4.22.0 (@lukekarrys) * [`82ae2a7`](82ae2a7) [#105](#105) postinstall for dependabot template-oss PR (@lukekarrys) * [`2855879`](2855879) [#104](#104) bump @npmcli/template-oss from 4.21.3 to 4.21.4 (@dependabot[bot]) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR does two things:
codeorsignal, it rejects with an error from the parent context to preserve that more useful stack traceChanges the error message fromI removed this from the PR since it could be a breaking change sincecommand failedto@npmcli/promise-spawn command failed. I feel likecommand failedlooks too generic when thrown in the context of the npm CLI and this makes it clear that the error came from spawning something.npmlooks for this error message. It would be better to give this a better message further up the stack.It also refactors a bit to remove one level of nesting. It uses the
Promise.withResolvers()pattern to hoist the resolve and reject functions since none of the work actually needs to be done within the Promise executor.Example
Here's a before and after of
npm rebuild --loglevel verboseof a failingpreinstallscript. Some output is removed for clarity/brevity.before
after