Skip to content

fix(handler): forward onBodySent and onRequestSent in DecoratorHandler and CacheHandler - #5708

Closed
marko1olo wants to merge 1 commit into
nodejs:mainfrom
marko1olo:fix/decorator-handler-body-sent-forwarding
Closed

fix(handler): forward onBodySent and onRequestSent in DecoratorHandler and CacheHandler#5708
marko1olo wants to merge 1 commit into
nodejs:mainfrom
marko1olo:fix/decorator-handler-body-sent-forwarding

Conversation

@marko1olo

Copy link
Copy Markdown
Contributor

Summary

DecoratorHandler.onBodySent was declared as a no-op () => {} instead of delegating to the wrapped handler. onRequestSent was not declared at all, so Request silently skipped calling it.

Since every built-in interceptor either extends DecoratorHandler (RedirectHandler, RetryHandler, …) or hand-forwards handler methods (CacheHandler), composing any interceptor onto a dispatcher silently dropped these two hooks for the user's handler.

Fixes #5695

Changes

  • DecoratorHandler.onBodySent now forwards via optional chaining to this.#handler.onBodySent?.(...args)
  • DecoratorHandler.onRequestSent added with the same forwarding pattern
  • CacheHandler gains onBodySent and onRequestSent forwarding (was missing entirely)
  • 4 new unit tests in test/decorator-handler.js covering delegation and graceful no-op when the inner handler omits the method

@marko1olo marko1olo closed this Aug 22, 2026
@marko1olo

Copy link
Copy Markdown
Contributor Author

Closing — #5696 was merged in the meantime and covers the same fix. Thanks for the quick turnaround upstream!

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

2 participants