Skip to content

fix(deduplicate): do not deduplicate requests with a body - #6240

Merged
mcollina merged 1 commit into
nodejs:mainfrom
arshsmith1:dedupe-skip-request-body
Nov 21, 2026
Merged

mcollina merged 1 commit into
nodejs:mainfrom
arshsmith1:dedupe-skip-request-body

Conversation

@arshsmith1

Copy link
Copy Markdown
Contributor

This relates to...

N/A

Rationale

The deduplicate interceptor builds its key from the origin, method, path and headers, but not the request body. undici allows a body on GET, and search APIs such as Elasticsearch's _search rely on it, so two concurrent requests to the same URL with different bodies were merged. Only the first body reached the server, and the second caller got the first caller's response:

const client = new Client(origin).compose(interceptors.deduplicate())
await Promise.all([
  client.request({ method: 'GET', path: '/_search', body: '{"tenant":"alice"}' }),
  client.request({ method: 'GET', path: '/_search', body: '{"tenant":"bob"}' })
])
// before: server hits 1, bob receives "results for {"tenant":"alice"}"
// after:  server hits 2, each caller receives its own results

In a service that shares one dispatcher across users, one user can receive another user's results. A body can be a stream and can't be compared cheaply, so requests that carry a body now skip deduplication and are sent as usual.

Changes

Features

N/A

Bug Fixes

  • interceptors.deduplicate() no longer merges requests that carry a body
  • Documented this in Interceptors.md
  • Added a regression test in test/interceptors/deduplicate.js. It fails on main (1 origin hit instead of 2) and passes with the fix

Breaking Changes and Deprecations

N/A

Status

Signed-off-by: arshiya tabasum <arshi@bugqore.com>
@codecov-commenter

codecov-commenter commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.72%. Comparing base (2d30c32) to head (870b1fb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6240      +/-   ##
==========================================
+ Coverage   91.71%   91.72%   +0.01%     
==========================================
  Files         113      113              
  Lines       44835    44842       +7     
==========================================
+ Hits        41121    41133      +12     
+ Misses       3714     3709       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lgtm

@mcollina
mcollina merged commit be1483d into nodejs:main Nov 21, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants