Skip to content

fix(interceptors): cache() and deduplicate() silently inert on Client/Pool without opts.origin - #5628

Merged
mcollina merged 1 commit into
nodejs:mainfrom
marko1olo:fix/interceptors-origin
Aug 1, 2026
Merged

fix(interceptors): cache() and deduplicate() silently inert on Client/Pool without opts.origin#5628
mcollina merged 1 commit into
nodejs:mainfrom
marko1olo:fix/interceptors-origin

Conversation

@marko1olo

Copy link
Copy Markdown
Contributor

Problem

When cache() or deduplicate() interceptors are composed onto a Client or Pool directly (not via Agent), opts.origin is not set. Both interceptors use opts.origin as the cache/dedup key without fallback — silently falling back to an empty string, making all requests share a single broken key and effectively disabling the interceptors.

Fix

Added getEffectiveOrigin() helper in lib/util/cache.js that derives origin from opts.origin or falls back to reconstructing it from opts.path. Both cache.js and deduplicate.js use this helper.

Tests

Added test/interceptors/interceptors-on-client.js — 4 tests, all pass.

Split from #5626 as requested by @mcollina.

@codecov-commenter

codecov-commenter commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.50%. Comparing base (2ab178a) to head (534caad).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
lib/interceptor/cache.js 40.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5628      +/-   ##
==========================================
- Coverage   93.50%   93.50%   -0.01%     
==========================================
  Files         110      110              
  Lines       38455    38467      +12     
==========================================
+ Hits        35959    35969      +10     
- Misses       2496     2498       +2     

☔ 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 b96a116 into nodejs:main Aug 1, 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