Skip to content

Commit d8e957b

Browse files
committed
fix race
1 parent 9e26c3e commit d8e957b

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/commands/actors/push.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,16 @@ Skipping push. Use --force to override.`,
411411
}
412412

413413
if (build.status === ACTOR_JOB_STATUSES.SUCCEEDED) {
414+
// Platform updates `taggedBuilds[buildTag]` asynchronously after the
415+
// build finishes. Wait until the tag points at this build so callers
416+
// that immediately `actor.start({ build: buildTag })` don't race it.
417+
if (buildTag) {
418+
while (Date.now() < deadline) {
419+
const a = await actorClient.get();
420+
if (a?.taggedBuilds?.[buildTag]?.buildId === build.id) break;
421+
await new Promise((resolve) => setTimeout(resolve, 1000));
422+
}
423+
}
414424
success({ message: 'Actor was deployed to Apify cloud and built there.' });
415425
// @ts-expect-error FIX THESE TYPES 😢
416426
} else if (build.status === ACTOR_JOB_STATUSES.READY) {

0 commit comments

Comments
 (0)