From 7f9f7a20b0434f9acb96b05e5f121a9ef29f53d6 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sun, 20 Jul 2025 16:20:41 +0200 Subject: [PATCH] ci/github-script/labels: limit cutoff to max 1 day It has only happened once, but the GitHub API suddenly returned a workflow run from a few weeks back. This lead to quickly hitting the rate limit for search requests. Prevent this from happening by going back a day max for the "recently updated" case. After roughly a day, every PR will have been touched by the regular batch processing anyway. Also save a few API requests, by taking bigger chunks of the search result. --- ci/github-script/labels.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ci/github-script/labels.js b/ci/github-script/labels.js index 7bbe1497d906..d7dbc2b2375c 100644 --- a/ci/github-script/labels.js +++ b/ci/github-script/labels.js @@ -292,11 +292,16 @@ module.exports = async function ({ github, context, core, dry }) { }) ).data.workflow_runs[0] - // Go back as far as the last successful run of this workflow to make sure - // we are not leaving anyone behind on GHA failures. - // Defaults to go back 1 hour on the first run. const cutoff = new Date( - lastRun?.created_at ?? new Date().getTime() - 1 * 60 * 60 * 1000, + Math.max( + // Go back as far as the last successful run of this workflow to make sure + // we are not leaving anyone behind on GHA failures. + // Defaults to go back 1 hour on the first run. + new Date(lastRun?.created_at ?? new Date().getTime() - 1 * 60 * 60 * 1000).getTime(), + // Go back max. 1 day to prevent hitting all API rate limits immediately, + // when GH API returns a wrong workflow by accident. + new Date().getTime() - 24 * 60 * 60 * 1000, + ), ) core.info('cutoff timestamp: ' + cutoff.toISOString()) @@ -308,6 +313,7 @@ module.exports = async function ({ github, context, core, dry }) { 'is:open', `updated:>=${cutoff.toISOString()}`, ].join(' AND '), + per_page: 100, // TODO: Remove in 2025-10, when it becomes the default. advanced_search: true, },