Repository navigation
Conversation
|
@OnePaiGu is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
| } | ||
| } | ||
|
|
||
| #[cfg(windows)] |
| cmd, | ||
| CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS | CREATE_BREAKAWAY_FROM_JOB, | ||
| ) | ||
| .map_err(|e| format!("Failed to start daemon: {}", e))?, |
|
This PR fixes #1407 ,which addresses the Windows handle-inheritance leak. |
…mpt gotchas - README.md / Capability: add browser vs testing comparison table with MCP servers, Chrome profiles, and use cases; document the mcp→tools conversion in deploy-agent.js (opencode silently ignores mcp: in markdown frontmatter); document agent-browser cold-start hang on Windows (vercel-labs/agent-browser#1408 handle-inheritance bug) and run-job.sh workaround (CLI warmup before MCP access); document per-job session isolation via AGENT_BROWSER_SESSION - README.md / Installation: add Windows troubleshooting — local MCP commands in ~/.config/opencode/opencode.json must be wrapped in cmd /c, otherwise spawn() fails with ENOENT (npm .cmd shims are not resolved without a shell) and opencode hangs silently - docs/workflow.md: add 'Writing agent system prompts — practical gotchas' section with three rules discovered during testing agent development but applicable to ANY MCP-using agent: 1. MCP tool names double the server prefix (agent-browser_agent_browser_open, not agent-browser_navigate) 2. Background server launch requires stdout/stderr redirection (& alone hangs forever) 3. All paths must be relative — sandbox silently rejects absolute paths No code changes — documentation only. npm test: 7/7 suites pass.
|
Independent confirmation that this is still worth merging: the leak reproduces on 0.37.1, so it has survived from 0.27.0 through roughly ten minor releases. Measured on Windows 11 Pro 10.0.26200 with PowerShell 5.1, full numbers in my comment on #1407: a cold One detail that argues for fixing it at this layer rather than in the npm wrapper: on 0.37.1 the node shim still spawns the native binary with |
Root Cause
Windows handle inheritance leak.
When the CLI process spawns the daemon via
Command::spawn(), the Rust standard library on Windows defaults tobInheritHandles = TRUE. This means the daemon child process inherits all handles marked as "inheritable" from the parent process, including:$output =capture2>&1redirectionTimeline:
Proposed Fix
Use the Windows CreateProcessW API directly in cli/src/connection.rs to spawn the daemon with bInheritHandles = FALSE , preventing the daemon from inheriting any handles from the parent process.
Key changes:
Verification
open --headed$output = & open --headed$LASTEXITCODE=0closethenopen --headed(script)openwhen daemon already runningEnvironment