Skip to content

fix(inngest): clear sync cursor in catch block to prevent stale cursor deadlock on prBackfill pagination errors - #852

Merged
jakharmonika364 merged 2 commits into
Coder-s-OG-s:mainfrom
yush-1018:fix/pr-backfill-stale-cursor-deadlock
Aug 4, 2026
Merged

fix(inngest): clear sync cursor in catch block to prevent stale cursor deadlock on prBackfill pagination errors#852
jakharmonika364 merged 2 commits into
Coder-s-OG-s:mainfrom
yush-1018:fix/pr-backfill-stale-cursor-deadlock

Conversation

@yush-1018

Copy link
Copy Markdown
Collaborator

####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) caused catch (e) to log the error and return without calling clearSyncCursor. This left repo_sync_cursors stuck at the last successful page (e.g. Page 4), trapping all future backfill runs in an infinite deadlock on Page 5.

####Changes Made

  • Error Cursor Cleanup: Added await clearSyncCursor(installationId, repoFullName, 'pull_requests'); inside the catch (e) block of backfillSingleRepo() in src/inngest/functions/pr-backfill.ts so failed cursors are cleaned up and future backfill runs start fresh.
  • Unit Tests: Added test case in src/inngest/functions/pr-backfill.test.ts verifying clearSyncCursor is invoked when pulls.list throws.

####Quality Control

  • Lint: ESLint passed with 0 errors and 0 warnings.
  • Unit Tests: All 8 unit tests in pr-backfill.test.ts pass cleanly.

#850

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@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 jakharmonika364 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jakharmonika364 jakharmonika364 added the Needs author reply Author need to reply label Jul 31, 2026

@jakharmonika364 jakharmonika364 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jakharmonika364
jakharmonika364 merged commit 40d8fc4 into Coder-s-OG-s:main Aug 4, 2026
2 of 3 checks passed
@ecsoc-sentinel ecsoc-sentinel Bot added ECSoC26-L2 Medium and removed ECSoC26-L3 Hard labels Aug 4, 2026
@yush-1018
yush-1018 deleted the fix/pr-backfill-stale-cursor-deadlock branch August 6, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants