Skip to content

fix: forward onResponseStarted through WrapHandler and UnwrapHandler#4840

Merged
metcoder95 merged 1 commit intonodejs:mainfrom
7rulnik:fix/response-started-interceptor
Feb 26, 2026
Merged

fix: forward onResponseStarted through WrapHandler and UnwrapHandler#4840
metcoder95 merged 1 commit intonodejs:mainfrom
7rulnik:fix/response-started-interceptor

Conversation

@7rulnik
Copy link
Contributor

@7rulnik 7rulnik commented Feb 25, 2026

This relates to...

N/A

Rationale

When fetch() goes through a dispatcher with composed interceptors, the handler is wrapped by WrapHandler and then unwrapped by UnwrapHandler. The onResponseStarted callback (which sets timingInfo.finalNetworkResponseStartTime) was not forwarded by either class, causing PerformanceResourceTiming.responseStart to always be 0.

Changes

Features

N/A

Bug Fixes

  • Added onResponseStarted() forwarding to WrapHandler (Unwrap Interface section)
  • Added onResponseStarted() forwarding to UnwrapHandler

Breaking Changes and Deprecations

N/A

Status

When using `agent.compose()` with interceptors, the handler goes through
a WrapHandler → UnwrapHandler round-trip. Neither class forwarded the
`onResponseStarted` callback, so `timingInfo.finalNetworkResponseStartTime`
was never set and `PerformanceResourceTiming.responseStart` was always 0.
Copy link
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

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.15%. Comparing base (088f72c) to head (e09f875).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4840   +/-   ##
=======================================
  Coverage   93.15%   93.15%           
=======================================
  Files         109      109           
  Lines       34228    34236    +8     
=======================================
+ Hits        31884    31892    +8     
  Misses       2344     2344           

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

@metcoder95 metcoder95 merged commit 8fe397e into nodejs:main Feb 26, 2026
36 of 37 checks passed
@7rulnik 7rulnik deleted the fix/response-started-interceptor branch February 26, 2026 09:38
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.

4 participants