@@ -1356,29 +1356,17 @@ detailsUrl: $detailsUrl
13561356 }) async {
13571357 final checkRunGuard = checkRunFromString (mergeQueueGuard);
13581358
1359- // Look up the PR in our cache first. This reduces github quota and requires less calls.
1360- PullRequest ? pullRequest;
1361- final id = checkRun.id! ;
1362- final name = checkRun.name! ;
1363- try {
1364- pullRequest = await PrCheckRuns .findPullRequestFor (_firestore, id, name);
1365- } catch (e, s) {
1366- log.warn ('$logCrumb : unable to find PR in PrCheckRuns' , e, s);
1367- }
1368-
1369- // We've failed to find the pull request; try a reverse look it from the check suite.
1370- if (pullRequest == null ) {
1371- final checkSuiteId = checkRun.checkSuite! .id! ;
1372- pullRequest = await _githubChecksService.findMatchingPullRequest (
1373- slug,
1374- sha,
1375- checkSuiteId,
1376- );
1377- }
1359+ final pullRequest = await findPullRequestCached (
1360+ checkRun.id! ,
1361+ checkRun.name! ,
1362+ slug,
1363+ sha,
1364+ checkRun.checkSuite! .id! ,
1365+ );
13781366
13791367 // We cannot make any forward progress. Abandon all hope, Check runs who enter here.
13801368 if (pullRequest == null ) {
1381- throw 'No PR found matching this check_run($id , $name )' ;
1369+ throw 'No PR found matching this check_run(${ checkRun . id } , ${ checkRun . name } )' ;
13821370 }
13831371
13841372 try {
@@ -1463,7 +1451,7 @@ $stacktrace
14631451 // We're doing a transactional update, which could fail if multiple tasks
14641452 // are running at the same time so retry a sane amount of times before
14651453 // giving up.
1466- const r = RetryOptions (maxAttempts: 3 , delayFactor: Duration (seconds: 2 ));
1454+ const r = RetryOptions (maxAttempts: 3 , delayFactor: Duration (seconds: 5 ));
14671455
14681456 return r.retry (() {
14691457 return UnifiedCheckRun .markConclusion (
@@ -1658,6 +1646,38 @@ $stacktrace
16581646 return const ProcessCheckRunResult .success ();
16591647 }
16601648
1649+ Future <PullRequest ?> findPullRequestCached (
1650+ int checkRunId,
1651+ String checkRunName,
1652+ RepositorySlug slug,
1653+ String headSha,
1654+ int checkSuiteId,
1655+ ) async {
1656+ final logCrumb = 'findPullRequestCached($checkRunId )' ;
1657+ PullRequest ? pullRequest;
1658+ // Look up the PR in our cache first. This reduces github quota and requires less calls.
1659+ try {
1660+ pullRequest = await PrCheckRuns .findPullRequestFor (
1661+ _firestore,
1662+ checkRunId,
1663+ checkRunName,
1664+ );
1665+ } catch (e, s) {
1666+ log.info ('$logCrumb : unable to find PR in PrCheckRuns' , e, s);
1667+ }
1668+ // We've failed to find the pull request; try a reverse look it from the check suite.
1669+
1670+ pullRequest ?? = await _githubChecksService.findMatchingPullRequest (
1671+ slug,
1672+ headSha,
1673+ checkSuiteId,
1674+ );
1675+ if (pullRequest == null ) {
1676+ log.warn ('$logCrumb : No pull request found' );
1677+ }
1678+ return pullRequest;
1679+ }
1680+
16611681 Future <ProcessCheckRunResult > _reRunFailed (
16621682 cocoon_checks.CheckRunEvent checkRunEvent,
16631683 ) async {
@@ -1667,12 +1687,13 @@ $stacktrace
16671687 // The CheckRunEvent.checkRun.pullRequests array is empty for this
16681688 // event, so we need to find the matching pull request.
16691689 final slug = checkRunEvent.repository! .slug ();
1670- final headSha = checkRunEvent.checkRun! .headSha! ;
1671- final checkSuiteId = checkRunEvent.checkRun! .checkSuite! .id! ;
1672- final pullRequest = await _githubChecksService.findMatchingPullRequest (
1673- slug,
1674- headSha,
1675- checkSuiteId,
1690+
1691+ final pullRequest = await findPullRequestCached (
1692+ checkRunEvent.checkRun! .id! ,
1693+ checkRunEvent.checkRun! .name! ,
1694+ checkRunEvent.repository! .slug (),
1695+ checkRunEvent.checkRun! .headSha! ,
1696+ checkRunEvent.checkRun! .checkSuite! .id! ,
16761697 );
16771698
16781699 final failedChecks = await UnifiedCheckRun .reInitializeFailedChecks (
0 commit comments