Repository navigation
Conversation
This branch has not been deployed
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.
Problem
When piping a halted
ProcessPromise($({ halt: true })) into anotherProcessPromise,ProcessPromise._pipe()placedthis.catch((e) => dest.break(e.exitCode, e.signal, e.cause))exclusively inside theelsebranch ofif (this.isHalted()).As a result, when a halted upstream process failed:
dest.break(...)was never called, so the downstream process saw clean EOF and resolved withexitCode: 0(silently masking upstream failures).ProcessPromiserejection had no.catch()handler, causing anUnhandledPromiseRejectionin Node.js even when awaiting the pipeline insidetry/catch.Additionally, pre-start failures (such as a missing
cwdor rejected async command interpolation) exposed three related edge cases:fill()accessedthis._zurk!.store[source]directly, throwingTypeError: Cannot read properties of null (reading 'store')when_zurkwas never initialized.cb()failures inrun()finalized without emitting'end'on$.ee, leaving piped streams open.break()returned early ifdestwas still'halted', and threwTrying to kill a process without creating one.ifdestwas'running'beforedest.childwas spawned (e.g., while resolving async command interpolation).Minimal reproduction
Changes
src/core.tsthis.catch((e) => check() && dest.break(e.exitCode, e.signal, e.cause))unconditionally forProcessPromisetargets in_pipe(), and guard the haltedstartlistener withcheck() && dest.run()sounpipe()d targets are neither started nor broken.ProcessPromise.break()to no-op when settled, callthis.kill(signal).catch(noop)whenthis.childexists, and finalize unstarted/pre-child destinations directly with aProcessOutputcarrying the upstreamexitCode,signal, andcause(preservingnothrow()).'end'on$.eefor pre-cb()failures inrun(), skipcb()if already settled, and keepcb()in its owntry/catch.fill()withthis._zurk?.store[source] || [].test/core.test.jspropagates rejection from halted and pre-start failing processescovering halted pipelines,unpipe(), multiple upstream sources,nothrow, pre-start missing-cwdfailures, pre-child async destinations, and asserting zerounhandledRejectionevents.build/core.cjs,.size-limit.jsonnpm run build && npm run build:size-limit).Verification
npm run buildnpm run test:typesnpm run test:sizenpm run fmt:checknpm run test:licensenpm run test:circularnode --test --test-name-pattern="pipe\(\)" test/core.test.js(28/28 passed)