Conversation
Node.js 20 sets a default 5-second socket timeout on HTTP connections. When code execution takes longer (cold sandbox starts, large file mounting, heavy pandas operations), the client destroys the socket before the server responds, causing "socket hang up" errors. Three fixes applied: 1. Streaming keepalive on /exec endpoint: sends whitespace every 3s to keep the TCP connection alive during long operations. JSON parsers ignore leading whitespace so this is fully transparent. 2. Non-blocking file I/O: moved MinIO response.read() into the thread pool executor (was blocking the asyncio event loop), and added stream_file_to_path() using fget_object for direct disk-to-disk transfer without loading files into memory. 3. Increased default sandbox pool size (SANDBOX_POOL_PY=5) to reduce cold-start frequency under concurrent load. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fix: Resolve socket hang up errors for large file execution
djuillard
pushed a commit
to On-Behalf-AI/LibreCodeInterpreter
that referenced
this pull request
Apr 21, 2026
fix: resolve socket hang up errors for large file execution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes socket hang up errors during large-file or slow
/execrequests by keeping the HTTP connection alive and removing blocking large-file reads from the asyncio event loop.This PR includes the
dev->maindelta at2529fe6over0dc767a:POST /execwhile execution is still runningFixes # (issue)
Type of change
How Has This Been Tested?
Verified locally on March 11, 2026.
pytest tests/unit/Result:
371 passedin0.73sAPI_BASE=http://localhost:8080 API_KEY=<repo .env key> pytest tests/functional/test_concurrent_file_exec.py -vResult:
1 passedin5.55shttp://localhost:8080/healthNotes:
http://localhost:8000, but this local Docker Compose stack exposes the API onhttp://localhost:8080, so the regression test was run against8080.pytest tests/unit/only; the new functional regression coverage is included here as local verification and should be treated as follow-up CI work.Reviewer Notes
POST /execremains JSON-compatible, but responses may now begin with keepalive whitespace before the final JSON payload.Checklist: