Back to Explore

mswjs/interceptors

GitHub
5 updates · last 90 days2 watchersOpen source

Last release:

@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: The repository shows recent upstream activity (last push 2026-07-25) and multiple version updates in late July 2026 (v0.42.3, v0.42.2, v0.42.1, v0.42.0), indicating ongoing development rather than maintenance mode.
  • Update cadence: Several updates across a short window in July 2026 (within days), with additional follow-up fixes in May and April 2026 (roughly every few weeks to two months), suggesting an active but not constant release rhythm.

AI summary generated

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • 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.

  • v0.42.2

    v0.42.2 introduces socket interception behavior changes around how connection listeners decide whether traffic is handled or passed through, and adds more realistic handling of mocked HTTP CONNECT tunnel refusals. While the release notes only call out two socket fixes, the diff also changes HTTP tunnel retargeting and verdict accounting for non-HTTP traffic, which can affect how data is routed and when pass-through occurs.

  • v0.42.1

    v0.42.1 primarily updates the browser build pipeline to ensure the CommonJS-only `debug` package is bundled for browser compatibility. In addition, it bumps the package version and removes some internal documentation markdown files from the repository.

  • v0.42.0

    v0.42.0 introduces wrap-based TCP/TLS interception and expands protocol coverage (notably CONNECT and improved Node networking execution). It also modernizes the interception internals by moving to new request/event abstractions and updating the public event payloads to include the request initiator.

    BreakingFeatures
  • v0.41.9

    v0.41.9 primarily fixes a potential memory leak related to fetch abort handling and updates several interceptor internals to use global symbols via Symbol.for. The release notes describe both areas at a high level, but the code diff also contains an additional API-level change in one interceptor class and subtle behavior changes around symbol identity.

  • v0.41.8

    v0.41.8 updates the patching behavior in `PatchesRegistry` to handle properties that are non-configurable but writable. The release notes describe the intent (patching non-configurable writable properties), and the code implements it with descriptor-aware logic and adds targeted tests.

  • v0.41.7

    v0.41.7 includes fixes aimed at Node.js 24 compatibility and correctness of mocked FetchResponse cloning. It preserves custom response status and URL across Response.clone, and sanitizes recorded header tuples to avoid extra internal arguments introduced by newer Node versions.

  • v0.41.6

    v0.41.6 focuses on making fetch response cloning safer inside the interceptors. Instead of calling Response.clone() directly, the code now uses a dedicated FetchResponse.clone() helper to avoid failures when cloning is restricted by the runtime.

  • v0.41.5

    v0.41.5 fixes an issue where the library could not detect configurable global values that are defined on a prototype instead of directly on globalThis. The code change introduces a new global patching mechanism (globalsRegistry) and updates fetch, XMLHttpRequest, and WebSocket interceptors to use it.

  • v0.41.4

    v0.41.4 adds a new `FetchRequest` utility and switches several internal interceptors to construct `FetchRequest` instances instead of using the native `Request` constructor directly. The new `FetchRequest` class adds Node/Undici-compatible handling for non-configurable HTTP methods and request modes, and related prototype adjustments are made to keep raw header recording working.

    Features
  • v0.41.3

    v0.41.3 makes a small change to the WebSocket interceptor override to improve typing. The release notes describe annotating the `readyState` property to use the standard `WebSocket['readyState']` type.

  • v0.41.2

    v0.41.2 adds a new public export, resolveWebSocketUrl, and centralizes its implementation in a dedicated utility module. Internally, the WebSocket override interceptor now imports this shared helper instead of defining its own local copy.

  • v0.41.1

    v0.41.1 is a small WebSocket-focused release. The documented change is a bug fix for resolving relative WebSocket connection URLs. The code diff, however, shows broader WebSocket URL normalization behavior changes (scheme rewriting, relative URL resolution, and stricter validation) that can impact how developers compare or store `WebSocket.url` and related event fields.

    Breaking
  • v0.41.0

    v0.41.0 introduces a bundling pipeline change to use tsdown. It also includes ClientRequest-related fixes around HTTP parser cleanup and passthrough socket listener removal, plus a documented CJS export behavior change for the /presets/node entry.

    BreakingFeatures