fix(inngest): clear sync cursor in catch block to prevent stale cursor deadlock on prBackfill pagination errors - #852
Conversation
…r deadlock on prBackfill pagination errors
|
@yush-1018 is attempting to deploy a commit to the codersogs-3057's projects Team on Vercel. A member of the Team first needs to authorize it. |
jakharmonika364
left a comment
There was a problem hiding this comment.
Clearing the cursor on any pulls.list error works for transient failures (502s, timeouts), but if the throw is actually coming from classifyPrAsAi on a specific PR's content (it's unguarded, unlike listReviews right below it which has its own try/catch), restarting from page 1 will just walk back to the same PR and fail the same way - cursor keeps getting cleared, deadlock isn't actually broken, just more expensive per attempt. Do we know which case #850 was actually hitting? If it's classification-triggered, wrapping classifyPrAsAi in its own try/catch (log + continue, same pattern as reviews) would be the more targeted fix.
####Overview
Fixes an issue in
prBackfill(src/inngest/functions/pr-backfill.ts) where a GitHub API error during pagination (e.g. 502 Bad Gateway or network timeout on Page 5) causedcatch (e)to log the error and return without callingclearSyncCursor. This leftrepo_sync_cursorsstuck at the last successful page (e.g. Page 4), trapping all future backfill runs in an infinite deadlock on Page 5.####Changes Made
await clearSyncCursor(installationId, repoFullName, 'pull_requests');inside thecatch (e)block ofbackfillSingleRepo()insrc/inngest/functions/pr-backfill.tsso failed cursors are cleaned up and future backfill runs start fresh.src/inngest/functions/pr-backfill.test.tsverifyingclearSyncCursoris invoked whenpulls.listthrows.####Quality Control
pr-backfill.test.tspass cleanly.#850