Skip to content

Settle spawnAsync on close so stdout/stderr are fully read - #1271

Merged
theoephraim merged 1 commit into
mainfrom
fix-spawn-async-stdio-race
Nov 2, 2026
Merged

theoephraim merged 1 commit into
mainfrom
fix-spawn-async-stdio-race

Conversation

@theoephraim

Copy link
Copy Markdown
Member

spawnAsyncHelper settled on the child's exit event, which can fire before the stdio pipes are drained. Under load a failing command could reject with empty stderr: bitwarden then couldn't recognize "Vault is locked.", skipped its re-unlock retry, and reported unknown (seen flaking in CI on #1269). Successful calls could likewise lose trailing stdout.

Now it settles on close. Since a child that leaves a background daemon holding its pipes (eg. op) would never fire close, it falls back 500ms after exit, settling with whatever arrived and destroying the streams.

Tests reproduce the gap deterministically: the child exits immediately and a grandchild sharing its stdio writes 100ms later (old code returns empty output), plus a check that a lingering daemon doesn't hang the call.

exit can fire before the stdio pipes are drained, so a fast failing command
could reject with empty stderr (bitwarden then reported 'unknown' instead of
re-unlocking). Settle on close instead, falling back 500ms after exit for
children that leave a daemon holding the pipes.
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

bumpy-frog

The changes in this PR will be included in the next version bump.

patch Patch releases

  • @varlock/1password-plugin 2.0.6 → 2.0.7
  • @varlock/bitwarden-plugin 2.0.2 → 2.0.3
  • @varlock/keepass-plugin 2.0.4 → 2.0.5
  • @varlock/native-helper-darwin 1.24.0 → 1.24.1
  • @varlock/native-helper-linux-arm64 1.24.0 → 1.24.1
  • @varlock/native-helper-linux-x64 1.24.0 → 1.24.1
  • @varlock/native-helper-win32-x64 1.24.0 → 1.24.1
  • @varlock/pass-plugin 1.0.3 → 1.0.4
  • @varlock/proton-pass-plugin 2.0.2 → 2.0.3
  • varlock 1.24.0 → 1.24.1

Bump files in this PR

Click here if you want to add another bump file to this PR


This comment is maintained by bumpy.

@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: Reviewed subprocess settlement, affected CLI callers, and regression coverage.

  • Output collection: spawnAsyncHelper now settles on close, preserving stdout/stderr received after exit.
  • Bounded fallback: A guarded 500 ms fallback settles and destroys captured streams when descendants keep the pipes open.
  • Regression coverage: Tests exercise delayed stdout/stderr and lingering descendants, with patch releases recorded for affected packages.

Validation passed: all 19 utils tests, utils typecheck, and all six subprocess tests under Bun. Additional Bun probes covered ENOENT, mixed stdio, and a 4 MiB output round trip. Validation was Linux-only; vendor CLIs were not exercised.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

@pkg-pr-new

pkg-pr-new Bot commented Nov 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

varlock

npm i https://pkg.pr.new/varlock@1271

@varlock/astro-integration

npm i https://pkg.pr.new/@varlock/astro-integration@1271

@varlock/cloudflare-integration

npm i https://pkg.pr.new/@varlock/cloudflare-integration@1271

@varlock/nuxt-integration

npm i https://pkg.pr.new/@varlock/nuxt-integration@1271

@varlock/vite-integration

npm i https://pkg.pr.new/@varlock/vite-integration@1271

@varlock/native-helper-darwin

npm i https://pkg.pr.new/@varlock/native-helper-darwin@1271

@varlock/native-helper-linux-arm64

npm i https://pkg.pr.new/@varlock/native-helper-linux-arm64@1271

@varlock/native-helper-linux-x64

npm i https://pkg.pr.new/@varlock/native-helper-linux-x64@1271

@varlock/native-helper-win32-x64

npm i https://pkg.pr.new/@varlock/native-helper-win32-x64@1271

@varlock/1password-plugin

npm i https://pkg.pr.new/@varlock/1password-plugin@1271

@varlock/bitwarden-plugin

npm i https://pkg.pr.new/@varlock/bitwarden-plugin@1271

@varlock/keepass-plugin

npm i https://pkg.pr.new/@varlock/keepass-plugin@1271

@varlock/pass-plugin

npm i https://pkg.pr.new/@varlock/pass-plugin@1271

@varlock/proton-pass-plugin

npm i https://pkg.pr.new/@varlock/proton-pass-plugin@1271

commit: 1e00988

@theoephraim
theoephraim merged commit db875a0 into main Nov 2, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant