Skip to content

v0.42.0

Choose a tag to compare

@kettanaito kettanaito released this 22 Jul 16:01

v0.42.0 (2026-07-22)

⚠️ BREAKING CHANGES

  • Node.js v22 is the minimal supported version.
  • getRawRequest utility has been removed. Use the initiator reference on request listeners directly.
  • /utils/node and getClientRequestBodyStream() has been removed. Use the initiator reference directly.
  • file:// protocol requests are unsupported with fetch the same way they aren't supported in Node.js 22 and 24 (improved compliance).
  • 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.