Conversation
There was a problem hiding this comment.
Bug: Background Server Terminates Prematurely
The code starts a background web server and prints a URL for users to access the results, but then the function returns immediately and the process exits, terminating the sandbox before the user can access the web server. Removing sandbox.kill() doesn't keep the sandbox alive—the process still exits naturally when the async function completes. The PR description explicitly states this breaks "the research-agent use-case where you want to open the generated page after the agent is run." The function needs to keep the process alive (e.g., with a signal handler like in custom-sandbox-domain-proxy example) to allow users to actually access the hosted results.
examples/mcp-claude-code-js/index.ts#L58-L62
e2b-cookbook/examples/mcp-claude-code-js/index.ts
Lines 58 to 62 in 3c6a013
Sandboxes should be removed automatically, not with explicit kill().
This breaks especially the research-agent use-case where you want to open the generated page after the agent is run, or the mcp client ones where you want to connect the gateway to claude etc.
Note
Remove explicit sandbox.kill() from MCP example scripts, keeping sandboxes alive while still closing MCP connections where used.
sandbox.kill()cleanup across MCP examples to keep sandboxes available post-run:examples/mcp-browserbase-js/index.ts— remove sandbox kill; closeMCPServerStreamableHttpon completion.examples/mcp-research-agent-js/index.ts— remove sandbox kill; closeMCPServerStreamableHttpon completion.examples/mcp-claude-code-js/index.ts,examples/mcp-client-js/index.ts,examples/mcp-custom-server-js/index.ts,examples/mcp-custom-template-js/index.ts,examples/mcp-groq-exa-js/index.ts— remove sandbox kill lines only.Written by Cursor Bugbot for commit 3c6a013. This will update automatically on new commits. Configure here.