Skip to content

Commit 68603cb

Browse files
chore: wip
1 parent e7246f4 commit 68603cb

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

src/dynamodb.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,22 @@ export const dynamoDb = {
146146
},
147147
})
148148

149-
// Wait a moment for container to start
150-
await new Promise(resolve => setTimeout(resolve, 1000))
151-
152-
// Verify container is running
153-
const verifyResult = Bun.spawnSync(['docker', 'ps', '-q', '-f', `name=${containerName}`])
154-
const runningContainer = verifyResult.stdout.toString().trim()
149+
// `docker run -d` exits once the container is created — but that may
150+
// include an image pull on a fresh CI runner, which can take many
151+
// seconds. Wait for the spawn to finish before polling so we don't
152+
// race the pull.
153+
await child.exited
154+
155+
// Poll for the container to appear, since `docker ps` may briefly lag
156+
// the run command's exit on slower runners.
157+
let runningContainer = ''
158+
for (let i = 0; i < 30; i++) {
159+
const verifyResult = Bun.spawnSync(['docker', 'ps', '-q', '-f', `name=${containerName}`])
160+
runningContainer = verifyResult.stdout.toString().trim()
161+
if (runningContainer)
162+
break
163+
await new Promise(resolve => setTimeout(resolve, 200))
164+
}
155165
if (!runningContainer) {
156166
throw new Error('Failed to start DynamoDB Local Docker container')
157167
}

0 commit comments

Comments
 (0)