Skip to content

Commit 2da6a0f

Browse files
committed
fix: cap abortable daytona execWithArgs output
1 parent b1f7c83 commit 2da6a0f

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

packages/core/src/sandbox/daytona-sandbox.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,10 @@ export class DaytonaSandbox implements Sandbox {
331331
options.env,
332332
);
333333
if (options.signal) {
334-
return await this.execWithSession(fullCommand, options);
334+
return await this.execWithSession(fullCommand, {
335+
...options,
336+
maxBuffer: options.maxBuffer ?? EXEC_OUTPUT_MAX_BUFFER,
337+
});
335338
}
336339
const result = await this.handle.process.executeCommand(fullCommand);
337340
return {

test/packages/core/daytona-sandbox.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,27 @@ describe("DaytonaSandbox", () => {
440440
expect(handle.process.getSessionCommandLogs).not.toHaveBeenCalled();
441441
expect(handle.process.deleteSession).toHaveBeenCalledTimes(1);
442442
});
443+
444+
it("caps abortable execWithArgs session output to the default buffer", async () => {
445+
const handle = createMockHandle();
446+
handle.process.getSessionCommandLogs.mockResolvedValue({
447+
stdout: "a".repeat(50 * 1024),
448+
stderr: "b".repeat(50 * 1024),
449+
});
450+
const sandbox = await createTestSandbox(handle);
451+
const controller = new AbortController();
452+
453+
const result = await sandbox.execWithArgs("gh", ["pr", "view", "1"], {
454+
signal: controller.signal,
455+
});
456+
457+
expect(result).toEqual({
458+
stdout: "a".repeat(40 * 1024),
459+
stderr: "b".repeat(40 * 1024),
460+
exitCode: 0,
461+
});
462+
expect(handle.process.executeCommand).not.toHaveBeenCalled();
463+
});
443464
});
444465

445466
describe("readFile", () => {

0 commit comments

Comments
 (0)