fix(deduplicate): detach the primary on abort instead of rejecting the group - #5765
Open
pacocartones wants to merge 1 commit into
Open
fix(deduplicate): detach the primary on abort instead of rejecting the group#5765pacocartones wants to merge 1 commit into
pacocartones wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5765 +/- ##
==========================================
+ Coverage 93.50% 93.53% +0.02%
==========================================
Files 110 110
Lines 39072 39439 +367
==========================================
+ Hits 36534 36888 +354
- Misses 2538 2551 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mcollina
requested changes
Sep 4, 2026
| acWaiter.abort() | ||
| strictEqual((await waiterOutcome)?.name, 'AbortError') | ||
|
|
||
| await sleep(50) |
Member
There was a problem hiding this comment.
Please do not use sleep, it's flaky.
| const primaryOutcome = primary.then(() => 'resolved', err => err) | ||
| const waiterOutcome = waiter.then(() => 'resolved', err => err) | ||
|
|
||
| await sleep(50) |
Member
There was a problem hiding this comment.
Please do not use sleep, it's flaky.
| const primaryOutcome = primary.then(() => 'resolved', err => err) | ||
|
|
||
| // Let the waiter join the coalesced group, then abort the primary. | ||
| await sleep(50) |
Member
There was a problem hiding this comment.
Please do not use sleep, it's flaky.
| requestsToOrigin++ | ||
| // Hold the response open long enough for the primary to abort while the | ||
| // waiter is still attached. | ||
| await sleep(300) |
Member
There was a problem hiding this comment.
Please do not use sleep, it's flaky.
…e group Aborting the first request of a coalesced group cancelled the shared dispatch, so every other caller waiting on it — including callers that passed no signal — was rejected with an AbortError. Coalescing was not transparent: whether your request succeeded depended on who asked first and whether they had a timeout. Hand the primary a proxied controller (same shape as the waiting handlers). Aborting it now settles only the primary and detaches it from the group; the underlying request is cancelled only once no member — primary or waiting handler — is left waiting. This also releases the pendingRequests entry when every member of a group aborts, so a later request never joins a group with no consumers left. With no waiters the abort still propagates exactly as before. Refs: nodejs#5711 Signed-off-by: Paco Cartones <pacocartones@users.noreply.github.com>
pacocartones
force-pushed
the
fix/5711-dedup-primary-abort-v2
branch
from
September 4, 2026 15:16
094431e to
06dcbf1
Compare
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.
Fixes #5711.
Problem
With
interceptors.deduplicate(), aborting the primary request of a coalesced group rejected every waiter withAbortError— even waiters that passed nosignal. The primary received the real dispatch controller, so its abort tore down the shared dispatch and rejected all members.Fix
The primary now receives a proxied controller (mirroring the existing
#createWaitingHandler). Aborting it detaches only the primary and defers to#maybeAbortRealDispatch, which tears down the shared dispatch only once no member (primary or waiter) is left waiting, releasing thependingRequestsentry viaonComplete. Pause/resume still forward to the real controller, so backpressure is unchanged. With no waiters, abort propagates exactly as before.Test
test/interceptors/deduplicate.js:deduplicate 38/38 + cache 88/88 + retry 16/16,
npm run lint— all green.