# Data flow — mswjs/msw

> Canonical page: https://codevetter.com/unpack/msw/data-flow

# Data flow — mswjs/msw

Scanned commit 6d6aef1640ace2ce2bd90252c71bdbc53262efd3 (2026-09-30). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

Sources normalize intercepted traffic into protocol frames before shared resolution. HTTP handlers parse matching inputs and invoke resolvers in order, with handler state owning one-time and generator behavior. Browser response transport serializes across worker ports, whereas Node responds through interceptor controllers. Cookies and WebSocket client metadata have distinct persistence paths, and SSE sends encoded frames through a ReadableStream.
- The worker serializes request metadata and an ArrayBuffer body, sends REQUEST with a transferred port/body, and the page reconstructs a FetchRequest before queuing a ServiceWorkerHttpNetworkFrame. — [src/mockServiceWorker.js#L335-L347](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/mockServiceWorker.js#L335-L347) [src/mockServiceWorker.js#L444-L459](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/mockServiceWorker.js#L444-L459) [src/browser/utils/deserialize-request.ts#L8-L13](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/browser/utils/deserialize-request.ts#L8-L13) [src/browser/sources/service-worker-source.ts#L304-L315](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/browser/sources/service-worker-source.ts#L304-L315)
- InterceptorSource receives request/controller pairs, stores HTTP frames in a WeakMap keyed by Request identity, and queues them; defineNetwork forwards frame events and supplies the current handler controller. — [src/core/experimental/sources/interceptor-source.ts#L32-L50](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/core/experimental/sources/interceptor-source.ts#L32-L50) [src/core/experimental/sources/interceptor-source.ts#L73-L83](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/core/experimental/sources/interceptor-source.ts#L73-L83) [src/core/experimental/define-network.ts#L181-L203](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/core/experimental/define-network.ts#L181-L203)
- HttpHandler.parse gathers cookies and URL params or invokes a custom predicate; predicate combines URL matching with the HTTP method, and extendResolverArgs exposes params and cookies. — [src/http/http-handler.ts#L138-L183](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/http/http-handler.ts#L138-L183) [src/http/http-handler.ts#L192-L199](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/http/http-handler.ts#L192-L199)
- GraphQL input comes from GET query parameters, POST JSON, or multipart operations/map/files; parsing selects the requested document operation, and GraphQLHandler caches parsed results per Request. — [src/graphql/parse-graphql-request.ts#L37-L66](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/graphql/parse-graphql-request.ts#L37-L66) [src/graphql/parse-graphql-request.ts#L121-L198](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/graphql/parse-graphql-request.ts#L121-L198) [src/graphql/graphql-handler.ts#L238-L256](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/graphql/graphql-handler.ts#L238-L256)
- executeHandlers awaits handlers sequentially and stops on a response; RequestHandler owns isUsed, generator iterator/results, and lazy finalize cleanup, including returning a thrown Response as the resolver result. — [src/core/utils/execute-handlers.ts#L39-L66](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/core/utils/execute-handlers.ts#L39-L66) [src/core/handlers/request-handler.ts#L306-L345](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/core/handlers/request-handler.ts#L306-L345) [src/core/handlers/request-handler.ts#L365-L424](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/core/handlers/request-handler.ts#L365-L424) [src/core/handlers/request-handler.ts#L442-L515](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/core/handlers/request-handler.ts#L442-L515)
- Browser mock responses cross the port as MOCK_RESPONSE using a transferable stream or buffered ArrayBuffer; the worker reconstructs Response, special-cases status zero, and buffers streamed navigation responses before committing navigation. — [src/browser/sources/service-worker-source.ts#L537-L562](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/browser/sources/service-worker-source.ts#L537-L562) [src/mockServiceWorker.js#L349-L355](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/mockServiceWorker.js#L349-L355) [src/mockServiceWorker.js#L410-L438](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/mockServiceWorker.js#L410-L438)
- Mock response cookies are forwarded to document.cookie and stored against request.url before respondWith; later credentialed requests merge document cookies, jar cookies, and explicit Cookie headers, with headers taking precedence. — [src/core/handlers/request-handler.ts#L424-L428](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/core/handlers/request-handler.ts#L424-L428) [src/core/handlers/request-handler.ts#L673-L680](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/core/handlers/request-handler.ts#L673-L680) [src/core/experimental/frames/http-frame.ts#L278-L280](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/core/experimental/frames/http-frame.ts#L278-L280) [src/core/utils/request/get-request-cookies.ts#L54-L75](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/core/utils/request/get-request-cookies.ts#L54-L75)
- WebSocket storage persists only client id/url and reconstructs remote handles that send BroadcastChannel commands; SSE client.send instead serializes payloads into UTF-8 event frames enqueued on a response stream. — [src/ws/websocket-indexeddb-client-store.ts#L25-L28](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/ws/websocket-indexeddb-client-store.ts#L25-L28) [src/ws/websocket-client-manager.ts#L62-L83](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/ws/websocket-client-manager.ts#L62-L83) [src/ws/websocket-client-manager.ts#L191-L209](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/ws/websocket-client-manager.ts#L191-L209) [src/sse/sse.ts#L267-L279](https://github.com/mswjs/msw/blob/6d6aef1640ace2ce2bd90252c71bdbc53262efd3/src/sse/sse.ts#L267-L279)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
