Skip to content

fix(core): settle shell spawn failures - #41301

Closed
kitlangton wants to merge 3 commits into
v2from
shell-spawn-ready
Closed

kitlangton wants to merge 3 commits into
v2from
shell-spawn-ready

Conversation

@kitlangton

@kitlangton kitlangton commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

What

Prevent shell commands that fail synchronously during process creation from leaving the shell tool and its session busy forever.

Before / After

Before: A command containing an invalid process argument, such as an embedded NUL byte, makes cross-spawn throw synchronously. The detached shell setup fiber dies before completing its readiness deferred, so Shell.create waits forever and the tool remains running.

After: Synchronous process-creation throws enter the adapter's existing PlatformError channel. The shell service maps that spawn failure to the existing AppProcessError and fails its readiness deferred, allowing the shell tool to settle with an error and the session to continue.

How

  • packages/util/src/cross-spawn-spawner.ts wraps synchronous cross-spawn invocation failures as PlatformError.
  • packages/core/src/shell.ts maps only process-spawn failures to AppProcessError before registering shell state, then fails the readiness deferred with that error.
  • Session-shell and HTTP shell-create boundaries retain their existing public error surfaces by treating unexpected process-creation failures as defects.
  • packages/core/test/tool-shell.test.ts reproduces the original NUL-byte trigger through the real shell tool and verifies that it settles with an error.

Scope

This only addresses failures before a shell process is successfully created. It does not change timeout, process-tree termination, or background-shell behavior.

Testing

  • bun run typecheck
  • bun run test test/tool-shell.test.ts from packages/core (20 passed)
  • bun run test from packages/util (4 passed)
  • bun run test from packages/core (1600 passed, 16 skipped, 2 unrelated failures: recorded HTTP transport timeout and user-plugin config pollution)
  • bun run lint (existing repository-wide lint failure in packages/session-ui/src/v2/components/prompt-input/index.tsx)
  • bun run lint:effect-patterns (existing repository diagnostics outside this change)

@kitlangton
kitlangton enabled auto-merge (squash) August 8, 2026 17:15
@kitlangton
kitlangton disabled auto-merge August 8, 2026 17:15
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

@github-actions github-actions Bot closed this Sep 8, 2026
auto-merge was automatically disabled September 8, 2026 22:15

Pull request was closed

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