Skip to content

Commit 07bea4f

Browse files
committed
fix(sandbox): add 30-second timeout to proxy wait loops
1 parent 7325350 commit 07bea4f

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

packages/cli/src/utils/sandbox.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,9 @@ export async function start_sandbox(
184184
);
185185
});
186186
debugLogger.log('waiting for proxy to start ...');
187-
// Simple wait loop using spawnAsync
188-
while (true) {
187+
// Simple wait loop using spawnAsync with 30s timeout
188+
const start = Date.now();
189+
while (Date.now() - start < 30000) {
189190
try {
190191
await spawnAsync('curl', ['-s', 'http://localhost:8877'], {
191192
timeout: 250,
@@ -194,6 +195,11 @@ export async function start_sandbox(
194195
} catch {
195196
await new Promise((r) => setTimeout(r, 250));
196197
}
198+
if (Date.now() - start >= 30000) {
199+
throw new FatalSandboxError(
200+
'Timed out waiting for proxy to start after 30 seconds',
201+
);
202+
}
197203
}
198204
}
199205
// spawn child and let it inherit stdio
@@ -718,8 +724,9 @@ export async function start_sandbox(
718724
);
719725
});
720726
debugLogger.log('waiting for proxy to start ...');
721-
// Simple wait loop using spawnAsync
722-
while (true) {
727+
// Simple wait loop using spawnAsync with 30s timeout
728+
const start = Date.now();
729+
while (Date.now() - start < 30000) {
723730
try {
724731
await spawnAsync('curl', ['-s', 'http://localhost:8877'], {
725732
timeout: 250,
@@ -728,6 +735,11 @@ export async function start_sandbox(
728735
} catch {
729736
await new Promise((r) => setTimeout(r, 250));
730737
}
738+
if (Date.now() - start >= 30000) {
739+
throw new FatalSandboxError(
740+
'Timed out waiting for proxy to start after 30 seconds',
741+
);
742+
}
731743
}
732744
// connect proxy container to sandbox network
733745
// (workaround for older versions of docker that don't support multiple --network args)

0 commit comments

Comments
 (0)