Skip to content

Commit da7ba83

Browse files
committed
Add some debug logging
1 parent d5482e7 commit da7ba83

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

tests/e2e/helpers/global-sandbox.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ export async function createTestSandbox(
6060
};
6161

6262
// Initialize the container — retried because the container may still be booting
63+
const headers = makeHeaders();
6364
const initResponse = await fetchWithRetry(
6465
() =>
6566
fetch(`${workerUrl}/api/execute`, {
6667
method: 'POST',
67-
headers: makeHeaders(),
68+
headers,
6869
body: JSON.stringify({ command: initCommand }),
6970
signal: AbortSignal.timeout(30_000)
7071
}),
@@ -96,6 +97,12 @@ export async function createTestSandbox(
9697
`Failed to set sleep after: ${sleepAfterResponse.status} - ${body}`
9798
);
9899
}
100+
101+
// Debugging
102+
console.log(
103+
'Sandbox Config',
104+
await fetch(`${workerUrl}/api/config`, { headers }).then((r) => r.json())
105+
);
99106
}
100107

101108
return {

tests/e2e/streaming-operations-workflow.test.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,12 @@ describe('Streaming Operations - sleep after', () => {
217217
test('should keep sandbox alive during execStream beyond sleepAfter value', async () => {
218218
const sandbox = await createTestSandbox({ sleepAfter: '3s' });
219219
try {
220-
const { workerUrl, headers } = sandbox;
220+
const { workerUrl } = sandbox;
221+
const headers = sandbox.headers();
221222

222223
const streamResponse = await fetch(`${workerUrl}/api/execStream`, {
223224
method: 'POST',
224-
headers: headers(),
225+
headers,
225226
body: JSON.stringify({
226227
command: "bash -c 'sleep 5; printf done'"
227228
})
@@ -250,7 +251,7 @@ describe('Streaming Operations - sleep after', () => {
250251
while (Date.now() < deadline) {
251252
const stateResponse = await fetch(`${workerUrl}/api/state`, {
252253
method: 'GET',
253-
headers: headers(),
254+
headers,
254255
signal: AbortSignal.timeout(5000)
255256
});
256257
expect(stateResponse.status).toBe(200);
@@ -262,6 +263,15 @@ describe('Streaming Operations - sleep after', () => {
262263
await new Promise((resolve) => setTimeout(resolve, 1000));
263264
}
264265

266+
// Debugging
267+
if (status !== 'stopped' && status !== 'stopped_with_code') {
268+
console.log(
269+
'Sandbox Config',
270+
await fetch(`${workerUrl}/api/config`, { headers }).then((r) =>
271+
r.json()
272+
)
273+
);
274+
}
265275
expect(status).toMatch(/^(stopped|stopped_with_code)$/);
266276
} finally {
267277
await cleanupTestSandbox(sandbox);

tests/e2e/test-worker/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,12 @@ console.log('Terminal server on port ' + port);
498498
});
499499
}
500500

501+
if (url.pathname === '/api/config' && request.method === 'GET') {
502+
return Response.json({
503+
sleepAfter: sandbox.sleepAfter
504+
});
505+
}
506+
501507
if (url.pathname === '/api/state' && request.method === 'GET') {
502508
const state = await sandbox.getState();
503509
return new Response(JSON.stringify(state), {

0 commit comments

Comments
 (0)