Skip to content

build(macos): parallelize native helpers with complete cancellation - #19651

Merged
nwparker merged 9 commits into
stablyai:mainfrom
espetro:upstream/parallel-native-builds
Sep 13, 2026
Merged

nwparker merged 9 commits into
stablyai:mainfrom
espetro:upstream/parallel-native-builds

Conversation

@espetro

@espetro espetro commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Build Orca’s three independent macOS helpers at the same time. Four fresh-build trials on one Mac averaged 76.712 seconds sequentially and 74.418 seconds concurrently: 2.294 seconds faster, about 3%. Cancellation waits for the other builds to stop before the launcher exits.

What Changed

  • Run the computer, keyboard-layout, and notification-status builds concurrently on macOS, with module-prefixed output.
  • Give each build its own process group. On failure or interruption, stop the groups, escalate surviving groups to SIGKILL after two seconds, and wait for every child’s close event.
  • Preserve the first external SIGINT/SIGTERM and re-raise it after cleanup. Spawn errors also settle through close; normal completion allows output to drain.
  • Keep the Windows launcher and Linux no-op paths unchanged. Preserve the contributor history and merge main through ef6eeab.

Why

These helpers have separate build directories and no ordering dependency. Overlapping the work reduces packaging time. Waiting for all close events fixes the original proposal’s early signal exit, which could leave sibling compilers running.

Linked Issue

No linked issue was provided with the original PR.

Visual Proof

N/A — build tooling only; no application UI or interaction change.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

macOS 26.6.2 arm64, Node 26.6.0, Swift 6.3.3; all commands used ORCA_BACKGROUND_LAUNCH=1. No helpers or Electron windows were launched.

Four real builds used the same copied source path, fresh .build directories, and ad-hoc signing:

Trial Sequential Concurrent
1 77.079 s
2 74.443 s
3 74.393 s
4 76.344 s

All builds exited successfully and produced arm64 + x86_64 helpers; the app signature verifies. Keyboard and notification binaries are byte-identical across all four trials. A further concurrent build (75.252 s) was compared against the final sequential build: both architectures’ machine code and linked libraries match, and the complete Swift helper matches after masking only LC_UUID, code-signature bytes, and N_OSO debug-object modification timestamps. This is a modest local result, not a claimed several-minute or all-machine speedup.

pnpm test config/scripts/build-native-for-platform.test.mjs config/scripts/pnpm-cli-invocation.test.mjs src/shared/child-process/child-process-import-boundary.test.ts: 24 tests pass across three files. Coverage includes concurrent launch, SIGINT/SIGTERM, mixed signal handlers, failed builds, ignored cancellation, grandchildren retaining output pipes, missing commands, and simulated Linux/Windows entry points. Restoring the original PR implementation makes both interrupt regressions fail: it exits after only one of three children finishes cleanup.

Node typecheck, all three changed-code quality gates, syntax and whitespace checks pass. Native Windows/Linux builds, full application build, and release-identity signing were not run; simulated entry points are not native platform coverage.

AI Disclosure

The original author disclosed Claude assistance. The takeover fixes, tests, and verification were performed with OpenAI Codex assistance.

Review

Cancellation, output completion, artifact equivalence, platform guards, and failure paths were reviewed. This changes only build orchestration; SSH execution, folder workspaces, runtime wire formats, and Git providers are unaffected.

Agent skill upstream boundary

  • Not applicable: no upstream skill implementation is copied or translated.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • Full lint/typecheck/test/application-build matrix (focused checks and actual native builds above pass)

Independent review follow-up

Handle stdout/stderr failures through the same compiler cleanup path, skip writes to broken output streams, and return failure even if an output error arrives after every child exits. The published version left two quiet compilers running when its output pipe closed; the fix leaves no survivors. Four added regressions cover both pipes and late errors; all 28 tests across three files and changed-code quality gates pass. Removing immediate failure status makes both late-error cases fail.

Parallel builds can use more CPU/RAM at once; concurrency is bounded to these three independent helpers. The measured ~3% gain applies to build:native callers. Existing build:mac commands retain their explicit sequential helper steps. Peak memory across all compiler processes was not measured.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 16 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 0e20d68a-856f-4304-82e0-010593087d8d

📥 Commits

Reviewing files that changed from the base of the PR and between 8709e65 and eb4eef6.

📒 Files selected for processing (4)
  • .github/workflows/computer-e2e.yml
  • config/scripts/build-native-for-platform.mjs
  • config/scripts/build-native-for-platform.test.mjs
  • config/scripts/computer-e2e-workflow.test.mjs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 21168792-d739-434b-9237-5e5e5f88e792

📥 Commits

Reviewing files that changed from the base of the PR and between 24392a0 and 8709e65.

📒 Files selected for processing (1)
  • config/scripts/build-native-for-platform.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/scripts/build-native-for-platform.mjs

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The macOS native build script starts detached concurrent pnpm builds with labeled output. It tracks child processes and waits for both error and close events. It terminates process groups on SIGINT, SIGTERM, or non-zero child exits. The parent process re-raises received signals after cleanup.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to 8709e

Concurrent macOS native builds may leave sibling build processes running when the parent is interrupted, potentially consuming resources or affecting subsequent builds. This termination behavior should be confirmed before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is detailed and covers the change, rationale, testing, limitations, and review considerations. However, the required Linked Issue section states that no issue was provided. Add the issue reference in the Linked Issue section, using the required Fixes #<issue-number> format, or update the repository process if this PR is intentionally exempt from issue linking.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: concurrent macOS native helper builds with cancellation handling.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f7a58bfd-c5bf-47aa-bbfa-ac7c077f8706

📥 Commits

Reviewing files that changed from the base of the PR and between 12f2c6b and 037feeb.

📒 Files selected for processing (1)
  • config/scripts/build-native-for-platform.mjs

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Comment on lines +31 to +32
child.kill(signal)
process.kill(process.pid, signal)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions

Length of output: 10387


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- changed file ---'
cat -n config/scripts/build-native-for-platform.mjs
printf '%s\n' '--- runtime declarations and relevant references ---'
for f in package.json .nvmrc .node-version; do
  if [ -f "$f" ]; then
    echo "--- $f ---"
    cat -n "$f"
  fi
done
rg -n --glob '!node_modules' --glob '!dist' --glob '!build' \
  'build-native-for-platform|resolvePnpmCliInvocation|spawnSync|process\.kill|child\.kill|pnpm' \
  config package.json .github 2>/dev/null | head -200

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -eu
node --version 2>&1 || true
printf '%s\n' '--- focused source ---'
sed -n '1,120p' config/scripts/build-native-for-platform.mjs
printf '%s\n' '--- package/runtime metadata ---'
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' \
  '"(engines|packageManager|volta|node)"|node-version|NODE_VERSION|Node\.js' \
  package.json .nvmrc .node-version .tool-versions README.md CONTRIBUTING.md .github 2>/dev/null | head -120

Repository: stablyai/orca

Length of output: 11116


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- repository status and diff context ---'
git diff -- config/scripts/build-native-for-platform.mjs
printf '%s\n' '--- all direct callers ---'
rg -n --glob '!node_modules' --glob '!dist' --glob '!build' \
  'config/scripts/build-native-for-platform\.mjs|build-native-for-platform' . 2>/dev/null | head -100

Repository: stablyai/orca

Length of output: 403


Terminate sibling builds before re-raising a child signal.

When runPnpmScript receives a signaled close event, child.kill(signal) targets the already-closed child, and process.kill(process.pid, signal) terminates only the parent. The other pnpm processes can continue and write artifacts after the build fails. Track the child processes, terminate the siblings, await their cleanup, and then re-raise the signal.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ Minor suggestions only.

Reviewed changes

  • Parallel macOS native-module builds — config/scripts/build-native-for-platform.mjs now runs the three native-module pnpm scripts (build:computer-macos, build:keyboard-layout-macos, build:notification-status-macos) concurrently via spawn + Promise.all, aggregating exit codes with Math.max, instead of sequentially via spawnSync.

The change is sound: the three builds write to distinct output directories and use separate temp dirs (plus computer's own SwiftPM .build), so there's no shared filesystem state, and resolvePnpmCliInvocation() returns shell: false on macOS. A couple of minor nits inline.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Address coderabbit review: concurrent builds kept writing native
artifacts after a sibling reported failure. Track spawned children,
kill remaining siblings on first nonzero exit, and forward SIGINT/
SIGTERM to all children.
@espetro

espetro commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 4776e74 to address the sibling-cleanup concern: spawned children are now tracked, remaining siblings receive SIGTERM as soon as one build exits nonzero (fail fast so no straggler keeps writing native artifacts), and SIGINT/SIGTERM on the parent are forwarded to all children.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ The new fail-fast logic is correct; one outstanding nit from the prior review is still actionable and now matters even more.

Reviewed changes

  • Fail-fast sibling termination — when one native-module build fails, terminateAll now sends SIGTERM to the sibling builds so they stop writing artifacts; the dead child.kill(signal) from the prior review is gone.
  • Parent signal handling — SIGINT/SIGTERM on the parent now terminate any still-running builds via the tracked children set instead of leaving them orphaned.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a29ad1d1-0ac5-4b9b-a73c-30ac6bb023b2

📥 Commits

Reviewing files that changed from the base of the PR and between 037feeb and 4776e74.

📒 Files selected for processing (1)
  • config/scripts/build-native-for-platform.mjs

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.

…ative builds

Address second coderabbit round:
- Detached process groups + negative-pid kill so SIGTERM reaches swift/
  swiftc descendants, not just the direct pnpm child (they could keep
  writing artifacts after fail-fast)
- Signal handlers preserve the received signal (SIGINT no longer becomes
  SIGTERM for children) and are removed before re-raising, so the parent
  actually dies instead of looping through terminateAll
- runPnpmScript settles only on close, never on error alone, so
  Promise.all cannot exit while children are still running
- Per-module output prefixes ([computer]/[keyboard-layout]/[notification-
  status]) match what the PR description always claimed; interleaved
  swiftc errors are now attributable
- Windows path untouched (early return before any of this runs)

execa/p-limit were considered and rejected: no new runtime deps for a
build script, and detached process groups give strictly stronger cleanup
than execa's direct-child kill.
@espetro

espetro commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Pushed a second-round fix addressing all remaining threads (including the ones on 4776e74):

Process-group teardown — children now spawn detached and teardown signals -child.pid, so SIGTERM reaches the swift/swiftc descendants rather than only the direct pnpm process. On group-kill failure it falls back to the direct child.

Signal fidelity — SIGINT and SIGTERM handlers are registered separately and forward the received signal (a parent Ctrl-C no longer becomes SIGTERM for children). The handler is removed before re-raising, so after children settle, the parent dies with the original signal (verified: exit 130 on SIGINT) instead of re-entering terminateAll forever.

Settle-on-close only — runPnpmScript records the error but resolves exclusively from the close event, so Promise.all can no longer exit while a child is still running.

Output prefixes — each child's stdout/stderr is piped through a [computer] / [keyboard-layout] / [notification-status] line prefixer, matching what the PR description claimed. Verified on a real concurrent macOS build: all three modules build green with attributable interleaved output.

On execa + p-limit: considered and rejected. This is a build script that currently has zero runtime dependencies; the same semantics (fail-fast cancellation, cleanup on parent exit, concurrency) come free here from detached process groups + Promise.all, and negative-pid group kill is stronger than execa's cleanup, which signals the direct child only. Happy to revisit if the repo would rather standardize on execa across build scripts.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: c868abd3-e241-4f38-982b-7e6cf37f4846

📥 Commits

Reviewing files that changed from the base of the PR and between 4776e74 and 24392a0.

📒 Files selected for processing (1)
  • config/scripts/build-native-for-platform.mjs

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

The process-group teardown itself is correct, but the signal/exit-status logic has two bugs that break the PR's core promise: on a real build failure the script never reaches process.exit(Math.max(...exitCodes)), and on Ctrl-C it does not die with 130. Both are reproducible (details inline).

Reviewed changes

  • Process-group teardown — each build now spawns detached: true into its own POSIX process group, and terminateAll negative-pid-kills the whole group so swift/swiftc descendants die too, not just the pnpm child.
  • Settle-on-close + signal fidelity — build promises resolve only from the child close event; a child that dies by signal attempts to re-raise that signal on the parent.
  • Per-module output prefixes — stdout/stderr are piped through a [computer] / [keyboard-layout] / [notification-status] line prefixer, resolving the prior "interleaved logs are unattributable" feedback.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…plit

Second-round coderabbit findings on 24392a0:
- Registration now uses the memoized handlerFor() instances so
  removeListener actually removes them (inline arrows were never
  registered, so the parent looped through terminateAll and hung)
- externalSignal is set only by the parent's own signal handlers; a
  sibling's fail-fast SIGTERM no longer masquerades as an external
  signal, so settle() resolves Promise.all with the failing module's
  exit code instead of leaving top-level await unsettled (exit 13)
- Also fixes a TDZ crash: handlerFor() was invoked at registration time
  before the signalHandlers const initialized

Verified: sibling fail-fast resolves failer=7 with no survivors;
external SIGINT kills children then the parent exits 130; real
concurrent macOS build green.
@espetro

espetro commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

All three findings fixed and pushed:

  1. Memoized handler registration — process.on now registers the same handlerFor(sig) instances that removal uses, so the re-raise path terminates the parent instead of re-entering terminateAll. This also surfaced a TDZ bug my earlier test missed: handlerFor('SIGINT') ran at registration time before signalHandlers initialized — caught it because the real build now executes the top-level registration eagerly.

  2. External vs sibling signal split — an externalSignal variable is set only by the parent's own signal handlers. settle() re-raises only when that is set; a sibling's fail-fast SIGTERM falls through and resolves Promise.all with the failing module's exit code (verified: failer=7, no survivors, proper exit). The unset case treats a child's signal exit as a nonzero code rather than a re-raise.

  3. Verified end-to-end: sibling fail-fast resolves correctly; external SIGINT → children get SIGINT → handlers removed → parent exits 130; real concurrent macOS build green.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • External-vs-sibling signal split — introduced externalSignal, set only by the SIGINT/SIGTERM handlers, so a sibling killed by fail-fast SIGTERM falls through to resolve(exitCode) instead of re-raising on the parent; Promise.all now settles and process.exit(Math.max(...exitCodes)) is reached.
  • Memoized handler removal — SIGINT/SIGTERM are registered via handlerFor(signal), so removeListener(received, handlerFor(received)) removes the actually-installed reference and the parent re-raise terminates with the original signal (exit 130 on SIGINT).

Both findings from the prior review (removeListener no-op; fail-fast siblings short-circuiting exit-code aggregation) are correctly fixed, and no new issues were introduced.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@OrcaWin OrcaWin changed the title build(macos): run native module builds concurrently build(macos): parallelize native helpers with complete cancellation Sep 12, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Wait for cancellation before exiting — stopBuilds(signal) centralizes idempotent process-group teardown and schedules the 2s SIGKILL escalation only while children remain; after Promise.all the parent clears the force timer and signal listeners, then re-raises an external signal or sets process.exitCode (natural exit, so drained output is not truncated instead of the previous process.exit).
  • Output-stream failure handling — process.stdout/process.stderr error listeners mark outputFailed, abort sibling builds, and force exit code 1 even when the error lands after every child has exited; pipePrefixed skips writes to a destroyed target.
  • Regression suite added — a macOS-gated build-native-for-platform.test.mjs covering concurrent launch, SIGINT/SIGTERM sibling wait and re-raise, fail-fast on failure, a default-handler child, an ignore-SIGTERM child reaped by the escalation timer, closed stdout/stderr consumers, late output errors, missing commands, descendant reaping, and simulated Linux/Windows entry points.

The two new commits resolve the prior review's remaining concerns cleanly, and the fail-fast/external-signal split and removeListener fixes from 8709e65 still hold. All Pullfrog threads on this PR are resolved.

Pullfrog  | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@nwparker

Copy link
Copy Markdown
Contributor

I like faster builds. Thanks

Will review + merge

…sure

- Bound the per-child close wait: two seconds after a child exits, reap
  its process group and destroy its pipes so a descendant that inherited
  stdout/stderr cannot hang `pnpm build:native` forever.
- Handle SIGHUP alongside SIGINT/SIGTERM so a terminal hangup reaches the
  detached compiler sessions instead of orphaning them.
- Pause a compiler's output stream when the launcher's stdout/stderr
  reports backpressure and resume on drain, so prefixed output no longer
  buffers without bound.
- Run build-native-for-platform.test.mjs in the computer-e2e
  mac-native-owner-smoke PR job and trigger that workflow on launcher
  changes; the tests are darwin-only and no other PR job runs on macOS.
- Report the first failing child's status: re-raise its signal, or use
  its exit code instead of Math.max over cancelled siblings.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Bounded cancellation waits — a new 2s per-child closeTimer (armed on exit, cleared on close) SIGKILLs the child's process group and destroys its stdout/stderr when a descendant keeps the pipes open, so close still fires and Promise.all settles.
  • First-failure attribution — firstFailure records the code/signal of the child whose failure started cancellation (only while !stopping), so siblings killed by fail-fast SIGTERM/SIGKILL no longer mask it; the final block re-raises that signal, or reports that code instead of the maximum sibling status.
  • SIGHUP forwarding — the launcher now handles SIGHUP alongside SIGINT/SIGTERM via the memoized handlerFor and re-raises it after cleanup, so compilers do not outlive a terminal hangup.
  • Output backpressure — pipePrefixed pauses the child stream when the parent's stdout/stderr reports writableNeedDrain and resumes it on drain/close, bounding the launcher's own output buffer.
  • macOS CI coverage — the mac-native-owner-smoke job now runs the darwin-only cancellation suite with --config config/vitest.config.ts, path triggers were extended, and new tests cover first-failure status, signal re-raise, descendant reaping, and backpressure.

I traced the new exit-status paths (non-zero exit, spawn error, signal death, external signal, descendant-held pipes, late output error) and the backpressure/close-timer interaction. Exit status is correct in each, close still fires after the timer destroys a paused stream, and the pause/resume listeners do not leak or double-resume. The pre-existing concern about output that is still buffered when stdout stalls is a deliberate wait-bounding trade-off and does not hide a failure.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

… fail on ignored re-raised signal

The descendant reap timer started on every child 'exit' and fired even when
'close' was late only because the launcher paused the pipe for its own stdout
backpressure, destroying pipes with compiler output still queued. Arm the
countdown only while the pipes are actually draining: clear it on 'pause' and
re-arm on 'resume' after exit. Write the reap notice to stderr since stdout
is the stream that may be blocked.

Re-raising a child's fatal signal is a no-op when Node ignores it (SIGPIPE),
so set a non-zero exit code first; a failed build no longer exits 0.

Tests: stall the launcher's stdout consumer past the reap timeout and assert
every kernel-accepted compiler line still arrives; kill the computer build
with SIGPIPE and assert the launcher exits 1.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Reap timer respects output backpressure — armReap now returns without arming the 2s close timer while child.stdout/child.stderr is paused, and re-arms on resume once the child has exited, so compiler output still buffered in the pipe is drained instead of destroyed mid-write.
  • Nonzero exit when a re-raised signal is ignored — the firstFailure.signal branch sets process.exitCode = 1 before process.kill, so a build killed by a signal Node ignores (e.g. SIGPIPE) still reports failure rather than exiting 0.
  • Regression coverage — new failure-sigpipe and stalled-consumer cases plus a waitFor helper; the stall test resumes the consumer past the reap timeout and asserts every line the compiler pushed into the pipe is delivered.

I traced the new pause/exit interaction: a closed consumer routes through pipePrefixed's close handler into resume, the timer re-arms on resume only after exited, and close still clears it. The stalled-consumer assertion is exact, so it would fail if the timer destroyed the pipes while paused. Ran the non-darwin tests locally (27 passed, 21 darwin-gated skipped) and oxlint is clean.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 81c3d18 into stablyai:main Sep 13, 2026
33 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