fix(pr): rewrite completion queue to be truly serial#340
Merged
Conversation
The previous p-limit(1) approach only serialized the inner merge block, but executeItem calls still ran concurrently — meaning multiple PRs would attempt merge simultaneously. PR #18 would fail immediately before #16's conflict resolution even started. Replace the concurrent task model with a simple sequential drain loop: enqueue() collects items, drain() processes them one at a time in enqueue order. Each PR gets the full resolve-wait-retry cycle before the next one starts, so each sees the updated base branch after the prior merge.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #340 +/- ##
==========================================
- Coverage 93.23% 93.22% -0.01%
==========================================
Files 193 193
Lines 19571 19555 -16
Branches 3087 3085 -2
==========================================
- Hits 18247 18231 -16
Misses 1290 1290
Partials 34 34 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PR #339 set
p-limit(1)expecting serial execution, butexecuteItemcalls were still spawned concurrently viaenqueue() → ensureExecution(). The p-limit only gated the inner merge block, so multiple PRs would still fire their initial merge attempts simultaneously. This caused PR #18 to fail immediately (before #16's conflict resolution even started), and the completion queue appeared hung.Root Cause
Fix
Replaced the entire concurrent task model with a simple sequential
drain()loop:enqueue()now just collects items into an arraydrain()iterates items one at a time, running the full resolve → wait → retry cycle for each before moving to the next