Skip to content

Commit 626727b

Browse files
authored
fix(ci): remove isStaleCiRun to prevent ci pr hang on SSH host-key prompt (#10300)
Follow-up to #10297. The new \`isStaleCiRun\` helper runs \`git fetch origin\` inside the hash-mismatch retry path. In the \`bit_pr\` CircleCI job, \`origin\` is the default SSH remote and GitHub's host key isn't seeded in \`known_hosts\` for that job's shell — so the fetch hits an interactive "yes/no" host-key prompt and hangs the job until the 50-minute step timeout (seen on #10257). The \`bit_merge\` job avoids this only because it rewrites \`origin\` to an HTTPS+token URL via \`update_ssh_agent\`; \`bit_pr\` does not. \`isStaleCiRun\` was added during PR review to guard a hypothetical race: an older CI run finishing later could delete a newer run's lane and re-export stale snaps. In practice that race is unlikely, self-correcting (the next CI run on the latest commit publishes the correct lane), and only affects a PR lane — not main. Removing the guard restores the original simple retry from #10297, which is enough.
1 parent cdba458 commit 626727b

1 file changed

Lines changed: 0 additions & 32 deletions

File tree

scopes/git/ci/ci.main.runtime.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -856,14 +856,6 @@ export class CiMain {
856856
return await this.exporter.export();
857857
} catch (e: any) {
858858
if (!isHashMismatchErr(e) || attempt === maxAttempts) throw e;
859-
if (await this.isStaleCiRun()) {
860-
this.logger.console(
861-
chalk.yellow(
862-
`Export failed with lane hash mismatch on "${laneIdStr}" and the PR branch has advanced past our commit. Not retrying - a newer CI run will publish the correct lane.`
863-
)
864-
);
865-
throw e;
866-
}
867859
this.logger.console(
868860
chalk.yellow(
869861
`Export attempt ${attempt}/${maxAttempts} failed with lane hash mismatch on "${laneIdStr}" (likely a concurrent CI push). Deleting remote lane and retrying.`
@@ -889,30 +881,6 @@ export class CiMain {
889881
throw new Error(`exportWithRetryOnLaneHashMismatch: exhausted ${maxAttempts} attempts for lane ${laneIdStr}`);
890882
}
891883

892-
/**
893-
* Returns true when the PR branch on the remote has advanced past our local HEAD, meaning a
894-
* newer commit was pushed to the branch while this CI run was in flight. Best-effort: when we
895-
* can't determine the branch or reach the remote we return false (don't block retry).
896-
*/
897-
private async isStaleCiRun(): Promise<boolean> {
898-
try {
899-
const branch = await this.getBranchName();
900-
if (!branch) return false;
901-
const localSha = (await git.revparse(['HEAD'])).trim();
902-
// `--` separator and fully-qualified ref so a branch name starting with `-` can't be
903-
// interpreted as a git option (defense in depth for untrusted PR branches).
904-
await git.raw(['fetch', 'origin', '--', `refs/heads/${branch}:refs/remotes/origin/${branch}`]);
905-
const remoteSha = (await git.revparse([`refs/remotes/origin/${branch}`])).trim();
906-
if (remoteSha === localSha) return false;
907-
const mergeBase = (await git.raw(['merge-base', localSha, remoteSha])).trim();
908-
// local is strictly behind remote - remote has commits we don't.
909-
return mergeBase === localSha;
910-
} catch (err: any) {
911-
this.logger.console(chalk.yellow(`Unable to verify CI run freshness (assuming fresh): ${err?.message || err}`));
912-
return false;
913-
}
914-
}
915-
916884
/**
917885
* Archives (deletes) a lane with proper error handling and logging.
918886
* @param throwOnError - if true, throws on failure (use for critical operations like pre-export cleanup)

0 commit comments

Comments
 (0)