Skip to content

Commit 088ee5f

Browse files
Remove output size limit for command execution (#256)
The 10MB output size limit was overly defensive and caused unexpected errors when reading large files. Trust developers to manage their own resource usage. Changes: - Remove size check from parseLogFile in session.ts - Remove MAX_OUTPUT_SIZE_BYTES from config.ts - Remove maxOutputSizeBytes from SessionOptions - Update tests to verify large output works - Update documentation Fixes #255 Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Naresh <[email protected]>
1 parent 37a2686 commit 088ee5f

File tree

6 files changed

+35
-82
lines changed

6 files changed

+35
-82
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@cloudflare/sandbox': patch
3+
---
4+
5+
Remove output size limit for command execution
6+
7+
The 10MB output size limit that was intended to prevent OOM attacks has been removed. This limit was too restrictive for legitimate use cases like reading large media files. Developers are now trusted to manage their own resource usage and handle potential OOM situations.

docs/SESSION_EXECUTION.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ mkfifo "$sp" "$ep"
7373
## Error Handling and Limits
7474

7575
- Invalid `cwd` (foreground): we write a prefixed stderr line (binary prefix) indicating the failure and return exit code `1`.
76-
- Output size limit: large logs are rejected during parsing to protect memory (`MAX_OUTPUT_SIZE_BYTES`).
7776
- Timeouts: foreground commands can be configured to time out; an error is raised if the exit file does not appear in time.
7877

7978
## Why Two Patterns?
@@ -83,7 +82,7 @@ mkfifo "$sp" "$ep"
8382

8483
## Testing Notes
8584

86-
- Foreground tests cover silent commands (`cd`, variable assignment), error scenarios, multiline output, and size limits.
85+
- Foreground tests cover silent commands (`cd`, variable assignment), error scenarios, and multiline output.
8786
- Background/streaming tests cover concurrent output, stderr separation, and completion events.
8887
- The previous hang class was caused by FIFO open/close races in foreground on silent commands; process substitution removes this class entirely.
8988

package-lock.json

Lines changed: 15 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sandbox-container/src/config.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,6 @@ const COMMAND_TIMEOUT_MS = (() => {
3737
return val === 0 ? undefined : val;
3838
})();
3939

40-
/**
41-
* Maximum output size in bytes to prevent OOM attacks.
42-
* This is a security measure, not a timeout.
43-
*
44-
* Default: 10MB
45-
* Environment variable: MAX_OUTPUT_SIZE_BYTES
46-
*/
47-
const MAX_OUTPUT_SIZE_BYTES = parseInt(
48-
process.env.MAX_OUTPUT_SIZE_BYTES || String(10 * 1024 * 1024),
49-
10
50-
);
51-
5240
/**
5341
* Delay between chunks when streaming output.
5442
* This debounces file system watch events for better performance.
@@ -68,7 +56,6 @@ export const CONFIG = {
6856
INTERPRETER_SPAWN_TIMEOUT_MS,
6957
INTERPRETER_EXECUTION_TIMEOUT_MS,
7058
COMMAND_TIMEOUT_MS,
71-
MAX_OUTPUT_SIZE_BYTES,
7259
STREAM_CHUNK_DELAY_MS,
7360
DEFAULT_CWD
7461
} as const;

0 commit comments

Comments
 (0)