Packages

@mswjs/interceptors

0.45.12 · 11 Nov 2026MIT38M / weekRepositorynpmAtom feed

Your version

0.42.0

22 Jul 2026Where it was published

0.45.12 is the newest release of 0.42.x.

In short

5 breaking6 new13 fixed

  • Breaking

    Node.js v22 is the minimal supported version.

  • Breaking

    getRawRequest utility has been removed. Use the initiator reference on request listeners directly.

  • Breaking

    /utils/node and getClientRequestBodyStream() has been removed. Use the initiator reference directly.

  • Breaking

    file:// protocol requests are unsupported with fetch the same way they aren't supported in Node.js 22 and 24 (improved compliance).

  • Breaking

    HTTP-to-WebSocket upgrade requests throw with fetch the same way they do in Node.js. Other upgrade paths are unaffected and function correctly (http.request, WebSocket, undici).

Release note

  • Implements TCP/TLS wrap-based interception

Breaking changes

  • Breaking

    Node.js v22 is the minimal supported version.

  • Breaking

    getRawRequest utility has been removed. Use the initiator reference on request listeners directly.

  • Breaking

    /utils/node and getClientRequestBodyStream() has been removed. Use the initiator reference directly.

  • Breaking

    file:// protocol requests are unsupported with fetch the same way they aren't supported in Node.js 22 and 24 (improved compliance).

  • Breaking

    HTTP-to-WebSocket upgrade requests throw with fetch the same way they do in Node.js. Other upgrade paths are unaffected and function correctly (http.request, WebSocket, undici).

Features

  • Supports Node.js v26.

  • Supports CONNECT requests (fixes #481, closes #621).

  • Supports Undici fetch and request even when they aren't global.

  • Exposes the request initiator on the "request" event listener. The initiator property points to ClientRequest, XMLHttpRequest, or Request instance that initiated the intercepted request. If no instance can be reliably deduced, points to the raw net.Socket behind the connection.

Bug fixes

  • The library now executes more of the Node.js network that ever before. In fact, it executes the biggest possible amount of Node.js code. We are literally patching before the C++ bindings.

  • ClientRequest using sockets is now properly supported.

  • Now it doesn't matter how you import http/https (e.g. import * as http broke previously since we cannot patch that).

  • You can now end requests in the write callbacks. The documented limitation of Interceptors is gone.

  • Clients waiting for the secureConnect before writing anything are now properly supported.

  • TLS connections now correctly emit the keylog event on the socket.

  • Fixes an issue where the automatic Content-Type header added by Undici was not set on mocked responses.

  • socket.address(), as well as localAddress, localPort, localFamily, remoteAddress, remotePort, and `remoteFamily, are correctly set for both mocked and bypassed connections.

  • XMLHttpRequest: Fixes an issue where redirect responses weren't being followed.

  • XMLHttpRequest: Fixes an issue where the "progress" event for request.upload wasn't dispatched correctly.

  • XMLHttpRequest: total response body length is now computed only from the content-length mocked response header, just like it's done natively.

  • XMLHttpRequest: The progress event is now correctly emitted on the request for chunked responses.

  • XMLHttpRequest (JSDOM): Correctly performs the OPTIONS preflight request based on the JSDOM implementation (previously, preflight triggered for requests that shouldn't trigger it).

  • XMLHttpRequest: Implements mock response handling in accordance to the WHATWG XMLHttpRequest specification to improve browser compliance.

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.