Skip to content

fix: forward onBodySent/onRequestSent through interceptor handlers - #5696

Open
adarshx01 wants to merge 1 commit into
nodejs:mainfrom
adarshx01:fix/decorator-forward-body-sent
Open

fix: forward onBodySent/onRequestSent through interceptor handlers#5696
adarshx01 wants to merge 1 commit into
nodejs:mainfrom
adarshx01:fix/decorator-forward-body-sent

Conversation

@adarshx01

Copy link
Copy Markdown

Fixes #5695.

Request only calls onBodySent / onRequestSent when those methods exist on the handler. DecoratorHandler defined onBodySent as a no-op, so the chunk was swallowed, and onRequestSent was missing entirely. RetryHandler, RedirectHandler, and CacheHandler wrap the user handler themselves and never forwarded either hook.

Composing interceptors.retry(), redirect(), cache(), or anything that extends DecoratorHandler therefore silently dropped both callbacks. They now pass through the same way onRequestStart already does.

Test plan

  • node --test test/decorator-handler.js test/interceptors/body-sent-hooks.js
  • Bare Client still fires both hooks
  • Same after DecoratorHandler, interceptors.retry(), interceptors.cache(), and interceptors.redirect()

Made with Cursor

DecoratorHandler swallowed onBodySent with a no-op, and RetryHandler,
RedirectHandler, and CacheHandler never implemented the hooks, so
composing an interceptor silently dropped them.

Co-authored-by: Cursor <cursoragent@cursor.com>

@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

@codecov-commenter

codecov-commenter commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.47%. Comparing base (f387057) to head (4332410).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5696   +/-   ##
=======================================
  Coverage   93.47%   93.47%           
=======================================
  Files         110      110           
  Lines       38846    38876   +30     
=======================================
+ Hits        36310    36341   +31     
+ Misses       2536     2535    -1     

☔ 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.

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.

DecoratorHandler and CacheHandler do not forward onBodySent/onRequestSent to the wrapped handler

3 participants