npm / msw
msw
What changed in msw 1 to 3, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-26.
35 breaking17 new APIs and options5 behavior and defaults2 tooling49 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initmsw 339 changes
Breaking changes 15
The Content-Length request header is removed by bypass().
MSW no longer manages cookies in Node.js; cookie behavior follows the environment default. Browser behavior is unchanged.
The defineNetwork() API is the replacement for the removed handleRequest() utility.
MSW is now ESM-only, affecting how projects load and bundle the package.
MSW no longer patches setTimeout; advance fake timers normally for delayed mocked responses to resolve.
file:// requests now throw in Node.js, matching fetch behavior because fetch does not support them.
GraphQLLinkHandlers is renamed to GraphQLLink.
The handleRequest() utility is removed; use defineNetwork() instead.
Upgrade requests made via fetch() now throw in Node.js, matching fetch behavior because fetch does not support them.
The msw/native entrypoint is removed in favor of @msw/react-native.
The minimal supported Node.js version is v22; Node.js v18 and v20 support is deprecated.
The onUnhandledRequest option is renamed to onUnhandledFrame.
This now returns null in handlers in all environments; use the cookies resolver argument for cookie-based logic.
TypeScript 5.9 is the minimum supported version; support for 5.1 and 5.2 is deprecated, and versions 6.0 and 7.0 are supported.
The WebSocket connection life cycle event is renamed from connection to websocket:connection.
New APIs and options 7
GraphQL is exported from msw/graphql and handled as an optional peer dependency.
MSW now supports GraphQL subscriptions.
MSW now supports GraphQL v17.0.
Import individual utilities such as delay or passthrough from msw/utils for a smaller bundle footprint.
MSW can now intercept page navigations and form submissions.
A new WebSocket life cycle event lets consumers listen to connection errors.
A new WebSocket Extension API enables better custom experiences.
Behavior and default changes 2
Intercepted request headers can now be modified in passthrough scenarios.
worker.stop() now returns a Promise; awaiting it matters only in in-flight critical scenarios.
Tooling 2
MSW now supports TypeScript v6.0 and v7.0.
MSW adds a Vite plugin.
Fixes and other changes 13
Optional path parameters and pipes are preserved in handler paths.
The request:match event now includes handler.
Adds ico to the common assets recognized by isCommonAssetRequest.
Prevents the worker from going idle.
Network sources expose network context on enable.
Reset handlers are disposed of when reset, preventing them from remaining active.
Supports virtual:msw imports in Vitest.
Treats CONNECT requests as the transport mechanism.
Fixed localStorage cookie persistence causing maximum quota exceeded errors.
Fixed in-flight requests being incorrectly passed through when performed before calling worker.stop().
Various issues related to network interception in Node.js are fixed.
MSW now supports Node.js v24 and v26.
Preventing page closure via a beforeunload listener no longer unregisters the MSW worker.
msw 266 changes
Breaking changes 17
In Node.js, toPublicUrl now removes search parameters.
The browser and react-native export conditions are ordered lower, changing package export resolution.
The compose export is removed.
The context export and related defaultContext, restContext, and graphqlContext exports are removed.
The createResponseComposition export is removed.
The rest object is renamed to http, so request handlers use http.get instead of rest.get.
The Life-cycle Events API now accepts a single object argument.
listHandlers replaces the .printHandlers() method.
Browser-side exports such as setupWorker and SetupWorkerApi must now be imported from msw/browser.
The NetworkError class is removed in favor of the standard Response.error().
Node.js 16 is no longer supported; use Node.js 18 or later for the global Fetch API.
Intercepted requests are represented as Fetch API Request instances.
The { once: boolean } request handler option replaces res.once() and allows a network error to be mocked once.
The response export is removed.
Resolvers now receive a single object containing request and return a Response, replacing the (req, res, ctx) => res() signature.
Mocked responses are represented as Fetch API Response instances.
TypeScript versions earlier than 4.7 are no longer supported.
New APIs and options 10
Adds the finalize API for handler cleanup.
Support handling connection upgrades with ws.onUpgrade.
Adds a public test() method to WebSocketHandler.
Use the network source architecture through defineNetwork.
Exports the AnyHandler type for developers to use.
Exports the GraphQLLinkHandlers type for use by developers.
Adds support for server-sent events (SSE).
Intercepted request bodies can be read as FormData.
FormData is supported as a mocked response body.
ReadableStream is supported as a mocked response body.
Behavior and default changes 3
The SSE response stream now invokes finalize when it ends.
Request error handling moves from the worker thread to the client thread.
The RequestHandler API is now public.
Fixes and other changes 36
Logging for concurrent requests is now handled properly.
Prevents event forwarding manually.
All frame listeners are removed when the client closes.
Prevents a frame abort listener leak.
Exports the NetworkApi type so developers can use it.
Fixes exporting default handler controllers.
Cookies are forwarded only when the response is used.
User-provided responses are no longer cloned.
Generator state is reset when .resetHandlers() or .restoreHandlers() is called.
The underlying SSE stream now respects request.signal, allowing request cancellation to affect the stream.
Prevent
infinitemode from throwing.Life-cycle events are now annotated correctly.
WebSocket connections are no longer logged in the console when there are no matching event handlers.
URL matching now supports wildcard ports.
GraphQL supports responses with the application/graphql-response+json content type.
The postinstall script now handles special characters, preventing installation issues in environments where they occur.
In Node.js, infinite delays no longer leave open handles.
ws.link supports relative URLs.
Updated the interceptors dependency to fix a memory leak.
Supports TypedDocumentString as a request predicate.
The SSE worker now respects the quiet option.
Server-Sent Events now handle multi-line messages.
Handles incomplete localStorage in Node.js v25.
Types used in HttpHandler are now published for developers to use.
Fixes response init in response:* events.
A File polyfill is used in Node.js.
Fixes an issue preventing request bodies from being properly read as FormData.
Fixes response patching issues when using a FormData response body.
Includes various improvements in Node.js network behavior compliance.
A bypassed request's referrerPolicy is no longer reset to a different value than the original.
Fixes the order of XMLHttpRequest events and readyState changes.
Fixes an issue that caused the onload event callback to be called twice.
Reading an XMLHttpRequest body with responseType arraybuffer no longer produces an incorrect buffer by assuming the body is a string.
XMLHttpRequest status remains 0 until the request actually resolves.
XMLHttpRequest upload events are supported when responding with a mocked stream response.
Fixes the order of XMLHttpRequest events when the request fails.
msw 13 changes
Breaking changes 3
Renames the SetupServerApi type to SetupServer.
Renames the SetupWorkerApi type to SetupWorker.
For React Native, throws and suggests a URL polyfill.