fix(inngest): prevent duplicate XP awards via strict webhook idempotency checks #547#616
fix(inngest): prevent duplicate XP awards via strict webhook idempotency checks #547#616prasiddhi-105 wants to merge 3 commits into
Conversation
…ency on webhook retries
ReviewHey @prasiddhi-105 looked at this one. Needs a small change before merge. Intent is good, and the PR is nice and small. CI is green too. But a couple things:
Ask: keep completing the recommendation on retries; only guard things that must run once; fix or drop the overstated PR text. Happy to re-check after that. Thanks ! |
…prevent stuck states
|
@prasiddhi-105 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. |
thank u for pointing out the partial failure crash recovery risk. I've refactored the logic to ensure that recommendation updates and cache clearances execute unconditionally on webhook retries, ensuring no rows get left stuck open. The |
ReviewHey @prasiddhi-105 rechecked after your updates. Still not ready to merge. Thanks for trying to address the earlier feedback (always complete the rec, keep activity_log only when inserted, return the real flag for unrecommended). The direction is right, but the branch is broken right now. What’s wrong:
What to do:
Ping me when that’s done and CI is green happy to re-review. Until then, please don’t merge. |
Summary
This PR resolves a critical distributed systems concurrency bug where a contributor could be awarded duplicate XP for a single merged Pull Request. By capturing and strictly validating the boolean return flag of
insertXpEvent, we guarantee that parallel or retried GitHub webhook deliveries caught by our database unique index constraint (xp_events_idempotency) gracefully no-op and early-return instead of erroneously completing downstream processes.Type of Change
Related Issue
Closes #547
What was changed?
src/inngest/functions/process-pr-event.tsto evaluate the assignment ofinsertXpEvent().if (!inserted) return;guard block immediately following the event creation insideawardRecommendedMerge(). This prevents identical concurrent webhook retry processing threads from bypass-updating row statuses, wiping active user caches, or writing duplicate rows to the transactionalactivity_log.Checklist
npm run dev)