Skip to content

Commit dae67ff

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(sandbox): enforce E2B output limits on success
Fail closed even when the E2B SDK resolves a command after reporting a callback overflow.
1 parent ac4a7bf commit dae67ff

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

apps/sim/lib/execution/remote-sandbox/conformance.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ describe.each(PROVIDERS)('sandbox conformance [%s]', (provider) => {
138138
mockE2BCommandsRun.mockImplementation(
139139
async (_command: string, options: { onStdout: (chunk: string) => void }) => {
140140
options.onStdout('12345')
141-
options.onStdout('6')
141+
try {
142+
options.onStdout('6')
143+
} catch {
144+
// E2B may report callback errors separately and still resolve the command.
145+
}
142146
return { stdout: '123456', stderr: '', exitCode: 0 }
143147
}
144148
)

apps/sim/lib/execution/remote-sandbox/e2b.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ class E2BSandboxHandle implements SandboxHandle {
8383
onStdout: limiter.stdout,
8484
onStderr: limiter.stderr,
8585
})
86+
if (limiter.exceeded()) {
87+
await Promise.resolve(this.sandbox.kill()).catch(() => {})
88+
return {
89+
stdout: '',
90+
stderr: 'Sandbox command output limit exceeded',
91+
exitCode: 137,
92+
outputLimitExceeded: true,
93+
}
94+
}
8695
return { stdout: result.stdout, stderr: result.stderr, exitCode: result.exitCode }
8796
} catch (error) {
8897
if (limiter.exceeded()) {

0 commit comments

Comments
 (0)