Skip to content

Commit 7dbd5ed

Browse files
crowlbotclaude
andcommitted
test: extend volume-ready wait with a post-list sleep
Initial fix polled `volumes list` and stopped when the new volume appeared, but the mount still raced — the cluster takes another beat after the volume is queryable before it's actually mountable. Add a configurable `postListSleepMs` (default 5s) after the list confirms, and bump the overall timeout to 30s. Each sandbox-with-volume run now spends ~5-15s waiting, which is well below the 60s sandbox timeout. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4d7901b commit 7dbd5ed

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

tests/sandbox.test.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,27 @@ const sandbox = async (...args: string[]) => {
1313

1414
/**
1515
* `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.
16+
* backend takes a moment to make the volume mountable inside a sandbox
17+
* even after it's queryable via `volumes list`. Poll the list endpoint
18+
* first, then sleep `postListSleepMs` to let the cluster sync — without
19+
* that extra sleep we still hit `VOLUME_NOT_FOUND` when the follow-up
20+
* `sandbox create --volume <id>:path` runs.
2021
*/
2122
async function waitForVolumeReady(
2223
volumeId: string,
23-
{ timeoutMs = 15_000, intervalMs = 500 } = {},
24+
{
25+
timeoutMs = 30_000,
26+
intervalMs = 500,
27+
postListSleepMs = 5_000,
28+
} = {},
2429
): Promise<void> {
2530
const deadline = Date.now() + timeoutMs;
2631
while (Date.now() < deadline) {
2732
const list = await sandbox("volumes", "list");
28-
if (list.includes(volumeId)) return;
33+
if (list.includes(volumeId)) {
34+
await new Promise((r) => setTimeout(r, postListSleepMs));
35+
return;
36+
}
2937
await new Promise((r) => setTimeout(r, intervalMs));
3038
}
3139
throw new Error(

0 commit comments

Comments
 (0)