Skip to content

fix(1270): throw descriptive error when opts.dispatcher–passed instance methods#5007

Merged
mcollina merged 1 commit intonodejs:mainfrom
rozzilla:fix/1270/throw-descriptive-error-when-opts.dispatcher–passed-instance-methods
Apr 9, 2026

Hidden character warning

The head ref may contain hidden characters: "fix/1270/throw-descriptive-error-when-opts.dispatcher\u2013passed-instance-methods"
Merged

fix(1270): throw descriptive error when opts.dispatcher–passed instance methods#5007
mcollina merged 1 commit intonodejs:mainfrom
rozzilla:fix/1270/throw-descriptive-error-when-opts.dispatcher–passed-instance-methods

Conversation

@rozzilla
Copy link
Copy Markdown
Contributor

@rozzilla rozzilla commented Apr 9, 2026

This relates to...

Fixes #1270

Rationale

When a user passes dispatcher as an option to Pool.request(), Client.request(), or any other instance method, it is silently ignored, since the request goes through the instance the method was called on, not the provided dispatcher. This is confusing and leads to hard-to-debug behavior, especially for users behind a proxy trying to combine Pool with ProxyAgent.

Changes

  • Strip dispatcher from opts via destructuring before forwarding to instance methods
  • Throw InvalidArgumentError in DispatcherBase.dispatch() if opts.dispatcher is present, with a message guiding the user to either use top-level functions or call the dispatcher directly
  • Add tests covering Pool.request() rejection, Client.request() rejection, and top-level request() still working with opts.dispatcher

Features

Bug Fixes

Breaking Changes and Deprecations

Status

…ce methods

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
@rozzilla rozzilla force-pushed the fix/1270/throw-descriptive-error-when-opts.dispatcher–passed-instance-methods branch from cf65295 to fe51bea Compare April 9, 2026 09:06
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.94%. Comparing base (51a27b7) to head (fe51bea).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5007   +/-   ##
=======================================
  Coverage   92.93%   92.94%           
=======================================
  Files         110      110           
  Lines       35735    35739    +4     
=======================================
+ Hits        33212    33216    +4     
  Misses       2523     2523           

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

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 0143e1b into nodejs:main Apr 9, 2026
35 checks passed
Copy link
Copy Markdown

@gurgunday-spendesk gurgunday-spendesk left a comment

Choose a reason for hiding this comment

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

lgtm

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.

ProxyAgent can not work with Pool request

4 participants