Skip to content

Commit 4d7901b

Browse files
crowlbotclaude
andcommitted
test: poll until volume is visible before mounting it
`sandbox volumes create` returns the volume id immediately, but the backend may take a moment to make the volume visible to subsequent operations (mount, list). The `sandbox with volume mount` test hit this race on every CI run, surfacing as `VOLUME_NOT_FOUND` when the follow-up `sandbox create --volume <id>:path` call ran before the volume was queryable. Adds a `waitForVolumeReady` helper that polls `volumes list` for up to 15s (500ms interval) after creation, and inserts a call between the volume creation and the mount in the affected test. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 34794b5 commit 4d7901b

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/sandbox.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,28 @@ const sandbox = async (...args: string[]) => {
1111
return (await $.raw`deno sandbox ${args.join(" ")}`.text()).trim();
1212
};
1313

14+
/**
15+
* `sandbox volumes create` returns the volume id immediately, but the
16+
* backend may take a moment to make the volume visible to subsequent
17+
* operations (mount, list). Poll `volumes list` until the volume appears
18+
* to avoid a flaky `VOLUME_NOT_FOUND` race when the next step tries to
19+
* mount it.
20+
*/
21+
async function waitForVolumeReady(
22+
volumeId: string,
23+
{ timeoutMs = 15_000, intervalMs = 500 } = {},
24+
): Promise<void> {
25+
const deadline = Date.now() + timeoutMs;
26+
while (Date.now() < deadline) {
27+
const list = await sandbox("volumes", "list");
28+
if (list.includes(volumeId)) return;
29+
await new Promise((r) => setTimeout(r, intervalMs));
30+
}
31+
throw new Error(
32+
`Timed out waiting for volume ${volumeId} to become visible via 'volumes list'`,
33+
);
34+
}
35+
1436
Deno.test("sandbox create", async () => {
1537
const sandboxId = await sandbox(
1638
"create",
@@ -143,6 +165,7 @@ Deno.test("sandbox with volume mount", async () => {
143165
"--region",
144166
"ord",
145167
);
168+
await waitForVolumeReady(volumeId);
146169

147170
const sandboxId = await sandbox(
148171
"create",

0 commit comments

Comments
 (0)