Fix WS stream timeout killing long-running streams#400
Fix WS stream timeout killing long-running streams#400whoiskatrin wants to merge 1 commit intomainfrom
Conversation
The WebSocket transport applied a fixed 2-minute total-duration timeout to streaming requests, breaking execStream and process log streams that run longer than 2 minutes. Convert to an inactivity-based idle timeout (default 5 minutes) that resets on every chunk, and make both the request and stream idle timeouts user-configurable via SandboxOptions or environment variables. Closes #398
🦋 Changeset detectedLatest commit: 326eebc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
OpenCode Review
The timeout fix looks solid. Converting from total duration to idle timeout makes sense for long-running streams - agents and interactive processes should stay alive as long as they're producing output.
The implementation correctly separates streaming and non-streaming timeouts, with proper timer reset logic on every chunk. The configuration approach through both options and environment variables follows the existing pattern.
Environment variable parsing includes proper validation (positive integers only), and the defaults (2min for requests, 5min for stream idle) are reasonable for production use.
The timeout cleanup is handled consistently across all code paths (resolve, reject, error), preventing memory leaks from dangling timers.
Looks good to merge.
commit: |
🐳 Docker Images PublishedDefault: FROM cloudflare/sandbox:0.0.0-pr-400-8bc899dWith Python: FROM cloudflare/sandbox:0.0.0-pr-400-8bc899d-pythonWith OpenCode: FROM cloudflare/sandbox:0.0.0-pr-400-8bc899d-opencodeVersion: Use the 📦 Standalone BinaryFor arbitrary Dockerfiles: COPY --from=cloudflare/sandbox:0.0.0-pr-400-8bc899d /container-server/sandbox /sandbox
ENTRYPOINT ["/sandbox"]Download via GitHub CLI: gh run download 22148273705 -n sandbox-binaryExtract from Docker: docker run --rm cloudflare/sandbox:0.0.0-pr-400-8bc899d cat /container-server/sandbox > sandbox && chmod +x sandbox |
Summary
execStreamand process log streams stay alive as long as data is flowingrequestTimeoutMs(non-streaming, default 2min) andstreamIdleTimeoutMs(streaming, default 5min) user-configurable viaSandboxOptions.transportTimeoutsor environment variables (SANDBOX_REQUEST_TIMEOUT_MS,SANDBOX_STREAM_IDLE_TIMEOUT_MS)Closes #398