Skip to content

fix(sandbox): close exec() stdin on trusted-host and accept stdin input - #6022

Merged
vite-hub[bot] merged 5 commits into
mainfrom
fix/sandbox-exec-stdin
Dec 2, 2026
Merged

vite-hub[bot] merged 5 commits into
mainfrom
fix/sandbox-exec-stdin

Conversation

@onmax

@onmax onmax commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

On trusted-host, exec() started each command with an open stdin pipe that the caller could not write to or close. A command that reads stdin, such as cat, wc -l, or rg auth without a path, waited until its timeout, or forever without one. A Workspace Session runs its commands through the same exec(), so it hung too.

What changed

  • trusted-host exec() now starts the command with stdin connected to /dev/null. cat and wc -l read empty input, and rg auth searches the working directory as it does in a terminal. spawn() is unchanged.
  • exec() takes a new stdin option with text or bytes: session.exec("wc", ["-l"], { stdin: "a\nb\n" }). Trusted-host, container, Vercel, and Cloudflare accept this input and close stdin afterwards. A built-in session that cannot deliver input, such as Crabbox, throws SANDBOX_EXEC_STDIN_UNSUPPORTED instead of silently discarding it. Custom runtimes implement input in their own session.exec().
  • Vercel and Cloudflare keep collected command output when input is supplied. Cloudflare retains the exec() deadline, and fatal I/O errors stop only the affected command.
  • SandboxSpawnOptions keeps stdin?: boolean. It now extends Omit<SandboxExecOptions, "stdin">.
  • The Sandbox README says how exec() handles stdin.

This follows the plan decision for #5972: exec() closes stdin unless the caller passes stdin content.

Verification

  • On main, session.exec("cat", [], { timeout: 3_000 }) rejects with TimeoutError: The operation was aborted due to timeout. The regression verifies that cat and wc -l finish without input, that text and bytes arrive, and that sending 4 MiB to true still resolves.
  • Six regression cases failed at the original PR head and pass after the repair. Eight focused tests passed across the trusted-host, Crabbox, and hosted-provider fixtures, including native Cloudflare exec RPC coverage. The Sandbox build and eight diagnostic contract tests also passed.
  • Before the repair, vp test run in packages/sandbox passed 1046 tests with 7 skipped; the package typecheck, changed-file lint, and root diagnostic tests also passed.

Not verified

The original test was run on Linux. No live hosted runtimes were used for this repair; Cloudflare, Vercel, and Crabbox were verified through local fixtures.

Closes #5972

Prepared with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

@vite-hub

vite-hub Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —
View session Completed 2026-12-02T06:47:57.230Z 5m 44s
View session Cancelled 2026-12-02T06:45:38.581Z 2m 2s
View session Last seen running 2026-12-02T05:53:30.125Z 2s

Latest result

Pull request merged.

Final answers

Session

Pull request merged.

View session

PR #6022 is ready to merge. The assigned head retains the fixes for all six resolved review findings, and no new repair was needed. Hosted CI, changed-file lint, and eight focused stdin regressions passed. The Cloudflare RPC test could not run locally because the sandbox blocks loopback listeners.

Session

Updated the branch with main because main changed packages/sandbox/README.md, packages/sandbox/src/cloudflare.ts, packages/sandbox/src/error-diagnostics.ts and 12 more after its checks ran; waiting for checks on the new head.

Session

Updated the branch with main because main changed packages/sandbox/README.md, packages/sandbox/src/cloudflare.ts, packages/sandbox/src/error-diagnostics.ts and 12 more after its checks ran; waiting for checks on the new head.

Session

Updated the branch with main because main changed packages/sandbox/README.md, packages/sandbox/src/cloudflare.ts, packages/sandbox/src/error-diagnostics.ts and 12 more after its checks ran; waiting for checks on the new head.

Session

Updated the branch with main because main changed packages/sandbox/README.md, packages/sandbox/src/cloudflare.ts, packages/sandbox/src/error-diagnostics.ts and 12 more after its checks ran; waiting for checks on the new head.

Session

Updated the branch with main because main changed packages/sandbox/README.md, packages/sandbox/src/cloudflare.ts, packages/sandbox/src/error-diagnostics.ts and 12 more after its checks ran; waiting for checks on the new head.

Session

CI reconciliation completed; the same-head repair budget is exhausted.

@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 trusted-host EOF fix works. The new stdin option is not portable yet: Crabbox can drop the input, Vercel can reject after a normal exit, and the hosted runtimes can lose normal exec() output and deadline behavior.

Approach: Ignore stdin by default on trusted-host, but keep explicit input on an exec() path that preserves each runtime’s output and command lifecycle.

Reviewed changes

  • Trusted-host: Verified EOF for cat, text input, early exit, and timeout through the built public API.
  • Shared API and drivers: Traced exec() and spawn() across the built-in runtimes and custom sessions. Confirmed hosted failures with provider fixtures and checked the Vercel SDK and Crabbox CLI sources. No live hosted runtimes were used.
  • Tests: 156 tests passed and 6 were skipped across the focused remote-provider, Cloudflare, Crabbox, and container suites. The new trusted-host test fails on this runner because rg is not installed.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using pullfrog(high) | 𝕏

Comment thread packages/sandbox/README.md Resolved
@pkg-pr-new

pkg-pr-new Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@vite-hub/agent

pnpm add https://pkg.pr.new/@vite-hub/agent@6022

@vite-hub/auth

pnpm add https://pkg.pr.new/@vite-hub/auth@6022

@vite-hub/blob

pnpm add https://pkg.pr.new/@vite-hub/blob@6022

@vite-hub/browser

pnpm add https://pkg.pr.new/@vite-hub/browser@6022

@vite-hub/bundle

pnpm add https://pkg.pr.new/@vite-hub/bundle@6022

@vite-hub/channels

pnpm add https://pkg.pr.new/@vite-hub/channels@6022

@vite-hub/choices

pnpm add https://pkg.pr.new/@vite-hub/choices@6022

@vite-hub/cli

pnpm add https://pkg.pr.new/@vite-hub/cli@6022

@vite-hub/cms

pnpm add https://pkg.pr.new/@vite-hub/cms@6022

@vite-hub/codemods

pnpm add https://pkg.pr.new/@vite-hub/codemods@6022

@vite-hub/comments

pnpm add https://pkg.pr.new/@vite-hub/comments@6022

@vite-hub/connections

pnpm add https://pkg.pr.new/@vite-hub/connections@6022

@vite-hub/content

pnpm add https://pkg.pr.new/@vite-hub/content@6022

create-vitehub

pnpm add https://pkg.pr.new/create-vitehub@6022

@vite-hub/database

pnpm add https://pkg.pr.new/@vite-hub/database@6022

@vite-hub/device

pnpm add https://pkg.pr.new/@vite-hub/device@6022

@vite-hub/docs

pnpm add https://pkg.pr.new/@vite-hub/docs@6022

@vite-hub/email

pnpm add https://pkg.pr.new/@vite-hub/email@6022

@vite-hub/env

pnpm add https://pkg.pr.new/@vite-hub/env@6022

@vite-hub/forge

pnpm add https://pkg.pr.new/@vite-hub/forge@6022

@vite-hub/forms

pnpm add https://pkg.pr.new/@vite-hub/forms@6022

@vite-hub/gateways

pnpm add https://pkg.pr.new/@vite-hub/gateways@6022

@vite-hub/i18n

pnpm add https://pkg.pr.new/@vite-hub/i18n@6022

@vite-hub/kit

pnpm add https://pkg.pr.new/@vite-hub/kit@6022

@vite-hub/kv

pnpm add https://pkg.pr.new/@vite-hub/kv@6022

@vite-hub/markdown-template

pnpm add https://pkg.pr.new/@vite-hub/markdown-template@6022

@vite-hub/mcp

pnpm add https://pkg.pr.new/@vite-hub/mcp@6022

@vite-hub/presets

pnpm add https://pkg.pr.new/@vite-hub/presets@6022

@vite-hub/queue

pnpm add https://pkg.pr.new/@vite-hub/queue@6022

@vite-hub/rate-limit

pnpm add https://pkg.pr.new/@vite-hub/rate-limit@6022

@vite-hub/realtime

pnpm add https://pkg.pr.new/@vite-hub/realtime@6022

@vite-hub/runtime

pnpm add https://pkg.pr.new/@vite-hub/runtime@6022

@vite-hub/sandbox

pnpm add https://pkg.pr.new/@vite-hub/sandbox@6022

@vite-hub/schedule

pnpm add https://pkg.pr.new/@vite-hub/schedule@6022

@vite-hub/shell

pnpm add https://pkg.pr.new/@vite-hub/shell@6022

@vite-hub/source

pnpm add https://pkg.pr.new/@vite-hub/source@6022

@vite-hub/sync

pnpm add https://pkg.pr.new/@vite-hub/sync@6022

@vite-hub/ui

pnpm add https://pkg.pr.new/@vite-hub/ui@6022

vite-hub

pnpm add https://pkg.pr.new/vite-hub@6022

@vite-hub/web-container

pnpm add https://pkg.pr.new/@vite-hub/web-container@6022

@vite-hub/webhooks

pnpm add https://pkg.pr.new/@vite-hub/webhooks@6022

@vite-hub/workflow

pnpm add https://pkg.pr.new/@vite-hub/workflow@6022

@vite-hub/workspace

pnpm add https://pkg.pr.new/@vite-hub/workspace@6022

commit: 8aa0d0a

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

MCP eval dry run

  • Server: http://127.0.0.1:37583/mcp
  • Surface: 3c609a54e6e9942eb282f0b0fe721d50de99f6c0f6f54895d2a5a8dd6b0f5544
  • Baseline: /home/runner/work/_temp/base/size.json

Tool list size

The characters the model reads: the server instructions, and the name, description, and input schema of each tool.

Part Characters Delta
Total 1,463 0
Server instructions 288 0
list-pages 839 0
get-page 336 0

@vite-hub
vite-hub Bot merged commit 4730b92 into main Dec 2, 2026
48 checks passed
@github-actions github-actions Bot mentioned this pull request Dec 2, 2026
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.

Sandbox: exec() on trusted-host can hang when a command reads stdin

1 participant