feat(sync): add Octokit retry/throttle and rate-limited status
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
getInstallationOctokit,
|
||||
getRepository,
|
||||
getSpoonInstallationId,
|
||||
isRateLimitError,
|
||||
listPullRequests,
|
||||
syncForkBranch,
|
||||
} from './githubClient';
|
||||
@@ -360,13 +361,16 @@ const refreshOwnedSpoon = async (
|
||||
};
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
const rateLimited = isRateLimitError(error);
|
||||
await Promise.all([
|
||||
ctx.runMutation(internal.spoons.patchSyncFields, {
|
||||
spoonId,
|
||||
syncStatus: 'error',
|
||||
syncStatus: rateLimited ? 'rate_limited' : 'error',
|
||||
lastGithubRefreshAt: Date.now(),
|
||||
lastCheckedAt: Date.now(),
|
||||
lastError: message,
|
||||
lastError: rateLimited
|
||||
? `Rate limited by GitHub; will retry. ${message}`
|
||||
: message,
|
||||
}),
|
||||
ctx.runMutation(internal.syncRuns.patchInternal, {
|
||||
syncRunId,
|
||||
|
||||
Reference in New Issue
Block a user