Skip to content

Commit 87284a0

Browse files
crowlbotclaude
andcommitted
test: retry the sandbox create --volume call on race
Even with the post-list sleep extension (1 commit back), the sandbox-side volume lookup propagates separately from the deployng list endpoint. Retrying the mount-bearing `sandbox create` call up to 6 times (5s apart, ~30s budget) handles the residual race without papering over genuine backend failures. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7dbd5ed commit 87284a0

1 file changed

Lines changed: 29 additions & 8 deletions

File tree

tests/sandbox.test.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,35 @@ Deno.test("sandbox with volume mount", async () => {
175175
);
176176
await waitForVolumeReady(volumeId);
177177

178-
const sandboxId = await sandbox(
179-
"create",
180-
"--quiet",
181-
"--timeout",
182-
"60s",
183-
"--volume",
184-
`${volumeId}:/data/dataset`,
185-
);
178+
// The sandbox-side volume lookup hits a different service from the
179+
// volumes list endpoint we just polled; that service propagates the
180+
// new volume asynchronously, so a one-shot wait isn't enough. Retry
181+
// the mount-bearing create a few times.
182+
let sandboxId: string | undefined;
183+
let lastErr: unknown;
184+
for (let attempt = 0; attempt < 6; attempt++) {
185+
try {
186+
sandboxId = await sandbox(
187+
"create",
188+
"--quiet",
189+
"--timeout",
190+
"60s",
191+
"--volume",
192+
`${volumeId}:/data/dataset`,
193+
);
194+
break;
195+
} catch (err) {
196+
lastErr = err;
197+
await new Promise((r) => setTimeout(r, 5_000));
198+
}
199+
}
200+
if (!sandboxId) {
201+
throw new Error(
202+
`sandbox create with --volume kept failing: ${
203+
lastErr instanceof Error ? lastErr.message : String(lastErr)
204+
}`,
205+
);
206+
}
186207

187208
await sandbox(
188209
"exec",

0 commit comments

Comments
 (0)