@mswjs/interceptors is a low-level network interception library for Node.js, supporting interception and normalization of HTTP, XMLHttpRequest, fetch, and WebSocket traffic. It runs arbitrary logic on dispatched requests, converting intercepted requests to Fetch API Request instances and letting you construct Fetch API Response objects for intercepted HTTP requests. It’s useful as a lower-level component for higher-level mocking tools such as Mock Service Worker.
Project status
- Actively maintained, with an upstream push on 2026-11-01 and multiple updates in the weeks before it.
- Updates have been frequent, roughly several per week across late September and October 2026.
AI summary generated
Recent updates
v0.45.11
v0.45.11 fixes cancellation handling for streamed HTTP responses and preserves raw header values that contain separators. The code changes implement those documented fixes and add regression tests; no public API or dependency changes are evident.
v0.45.10
v0.45.10 fixes passthrough socket options, makes XMLHttpRequest aborts cancel pending handling and mocked response delivery, and avoids treating an abort race as an error after a request has already been handled. The diff also includes an undocumented XMLHttpRequest event-handler correction and changes Playwright installation in CI and release workflows.
v0.45.9
v0.45.9 ships a set of network and HTTP interception bug fixes. The documented changes focus on preventing double event emission, improving socket interception compliance, ensuring Authorization headers are set per request, and preserving paths that begin with a double slash.
Breakingv0.45.8
v0.45.8 is a small bug fix release focused on HTTP interception behavior for keep-alive sockets after a mocked response. It updates the socket abort logic and adds a regression test to ensure pending requests are aborted correctly when the client aborts them.
v0.45.7
v0.45.7 is a targeted network bug fix aimed at preventing overlapping writes on passthrough TLS sockets after the socket handle swap. The change adjusts the write decision logic in TcpSocketController and adds a compliance test covering writes that occur before the TLS handshake completes.
v0.45.6
v0.45.6 ships two bug fixes: it improves handling of HTTP exchanges inside real CONNECT tunnels, and it records raw headers correctly for Headers subclasses that store header values outside the native store. The code diff shows additional, larger internal refactors around CONNECT and TLS layering that are not mentioned in the release notes.
v0.45.5
v0.45.5 primarily fixes fetch response decompression, addressing Brotli truncation and preserving non-compressed mocked responses. The diff also includes several less-visible behavioral and typing changes around response handling and WebSocket extension typing that are not mentioned in the release notes.
Breakingv0.45.4
Release v0.45.4 primarily updates the `rettime` dependency to version 0.11.12. No application or API surface changes are shown in the code diff, aside from dependency and workspace configuration updates.
v0.45.3
v0.45.3 includes a websocket-related change described as a fix for “proper websocket handle types”. The code diff shows a broader TypeScript surface refactor where several websocket event and extension types were switched from connection classes to connection handle interfaces, and some exported types were renamed/reshaped.
v0.45.2
v0.45.2 adjusts the FetchInterceptor behavior so that the same Request object instance is emitted in both the "request" and "response" event listeners. The change is implemented by performing fetches using a cloned Request while emitting the original Request instance on the response event.
v0.45.1
v0.45.1 contains an HTTP-related dispose behavior fix. The release notes only mention reconnect attribution after dispose, but the code diff shows broader changes to how idle sockets and in-flight exchanges are handled during disposal, plus request-context propagation for socket close events.
v0.45.0
v0.45.0 introduces WebSocket “extensions” support, replacing the previous WebSocket protocol mechanism with a more general extension abstraction that can encode/decode frames, manage connection session frames, and expose per-connection APIs. It also fixes HTTP socket cleanup behavior when an interceptor is disposed, specifically addressing idle keep-alive sockets being left open.
BreakingFeaturesv0.44.0
v0.44.0 adds WebSocket custom protocol support to the interceptor, including protocol matching, handshake dispatch, and protocol-aware encoding and decoding of frames. It also improves HTTP interception passthrough behavior for non-HTTP sockets. The release notes document the feature at a high level, but the code introduces several API surface changes and more nuanced behavior that is not fully described.
Featuresv0.43.2
v0.43.2 addresses request header deletion behavior in the Node.js environment. The code now synchronizes headers deleted via `request.headers.delete()` onto the underlying outgoing Node HTTP message, with tests updated to cover Node vs browser behavior for XMLHttpRequest.
v0.43.1
v0.43.1 contains a targeted fix for XMLHttpRequest behavior around forbidden request headers. The change ensures that unsafe headers rejected by the Fetch headers guard are not forwarded to the underlying XHR request.
v0.43.0
v0.43.0 makes changes to how WebSocket-related types are exposed by the package. The main behavioral change is an API surface adjustment around exported WebSocket event types and connection-related interfaces.
Breakingv0.42.6
v0.42.6 is presented as a bug fix that reverts connection listener invocation behavior. In the actual code changes, the socket interceptor reworks how the "connection" event is emitted and how the socket controller decides passthrough versus claim, with additional timing changes in the HTTP request interception path.
v0.42.5
v0.42.5 focuses on several network and fetch robustness fixes. It addresses cancellation/hanging issues around streamed responses, ensures HTTP request parsers are properly freed during upgrade boundaries, and fixes passthrough socket listener leaks and half-open write behavior.
v0.42.4
v0.42.4 contains a set of bug fixes across the HTTP and WebSocket interceptors, mainly around parser error handling, keep-alive socket edge cases, and avoiding passthrough connection interception loops. The code diff also introduces a new shared internal AsyncLocalStorage context used to mark certain “internal” connections so they bypass socket consumer interception.
v0.42.3
v0.42.3 contains a bug fix aimed at correct handling of initial bytes when switching socket types during interception. The code changes add a more precise reset scheduling mechanism tied to HTTP message boundaries, plus regression tests for keep-alive passthrough scenarios and CONNECT.