Skip to content

Conversation

@kettanaito
Copy link
Member

@kettanaito kettanaito commented Oct 17, 2025

Warning

BREAKING CHANGE: We now handle mock response stream errors the same way Node.js handles them: write response headers as-is (e.g. 200 OK), then emit "error" on the response and abort the request without request errors. Previously, we coerced mock response stream errors to 500, which was wild magic and we shouldn't have done that.

Changes

Make the RequestController class accept a source object that implements the request handling methods (passthrough/respondWith/errorWith). We might eventually use this instead of the network frames in MSW as they are, effectively, the same thing.

Follow-ups

  • Make RequestController methods asynchronous to have a consistent function flow.
  • Breaking change: short-circuit request listener invocations as soon as one of them handles the request (now, we allow all listeners to run; also relied on in tests).

Todos

  • Confirm nock tests are passing with this change.
  • Confirm msw tests are passing with this change.

@kettanaito kettanaito force-pushed the feat/request-controller-revamp branch from 6960356 to 6632b32 Compare October 17, 2025 16:37
@kettanaito kettanaito marked this pull request as ready for review October 17, 2025 16:42
@kettanaito kettanaito force-pushed the feat/request-controller-revamp branch from 6632b32 to cb2debc Compare October 17, 2025 16:43
@kettanaito kettanaito merged commit c7b48ab into main Oct 19, 2025
3 checks passed
@kettanaito kettanaito deleted the feat/request-controller-revamp branch October 19, 2025 09:40
@kettanaito
Copy link
Member Author

Released: v0.40.0 🎉

This has been released in v0.40.0!

Make sure to always update to the latest version (npm i @mswjs/interceptors@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.

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.

Coercion of stream errors to 500 fails because headers have already been sent

2 participants