fix: Resolve socket hang up errors for large file execution#66
Merged
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>
djuillard
pushed a commit
to On-Behalf-AI/LibreCodeInterpreter
that referenced
this pull request
Apr 21, 2026
…ngup 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.
Summary
Changes
Streaming keepalive on
/exec(src/api/exec.py)StreamingResponsethat sends a space character every 3 seconds while execution is runningValidationError/ServiceUnavailableErrorso FastAPI exception handlers still return correct HTTP status codesresponsesparameterNon-blocking file I/O (
src/services/file.py,src/services/execution/runner.py)get_file_content():response.read()was running synchronously on the asyncio event loop, blocking all concurrent HTTP connections during large file downloads from MinIOstream_file_to_path()using MinIO'sfget_objectfor direct disk-to-disk transfer without loading files into memory_mount_files_to_sandbox()to use streaming, with non-blockingos.chown/os.chmodstream_file_to_pathtoFileServiceInterfaceConfiguration (
.env)SANDBOX_POOL_PYfrom 2 to 5 to reduce cold-start frequencyTest plan
tests/functional/test_concurrent_file_exec.py— uploads 50MB CSV, fires 5 concurrent file execs + 3 simple pings, asserts pings are not blockednode-fetch(exact CodeExecutor flow)🤖 Generated with Claude Code