Repository navigation
chore(msw): upgrade MSW to v3 while keeping v2 support - #2203
Conversation
- Bump the msw dev dependency to ^3.0.2. The `msw >=2.0.0` peer range already covers v3, and the package source works unchanged on both. - Rename the tests' `onUnhandledRequest` option to `onUnhandledFrame`, which v3 renamed (v3 silently ignored the old name). - Add an `msw-v2` vitest project that reruns the msw package tests with `msw` aliased to v2, so v2 support stays verified. - Note v2/v3 support and the renamed option in the MSW integration docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NNXLdknBGr7KSffPGDLHB9
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NNXLdknBGr7KSffPGDLHB9
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NNXLdknBGr7KSffPGDLHB9
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
orpc | 125071d | Commit Preview URL Branch Preview URL |
Oct 10 2026, 06:57 AM |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/bun
@orpc/client
@orpc/cloudflare
@orpc/contract
@orpc/experimental-effect
@orpc/evlog
@orpc/hibernation
@orpc/json-schema
@orpc/experimental-lock
@orpc/experimental-msw
@orpc/nest
@orpc/next
@orpc/node
@orpc/openapi
@orpc/opentelemetry
@orpc/pinia-colada
@orpc/pino
@orpc/publisher
@orpc/ratelimit
@orpc/server
@orpc/shared
@orpc/swr
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/zod
commit: |
MSW v3 requires Node.js 22.12+ (its interceptors call `Promise.withResolvers`), so the msw package tests fail on the Node 20 CI job. On older Node versions, exclude the package from the default (MSW v3) project; the MSW v2 project still runs its full suite there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NNXLdknBGr7KSffPGDLHB9
Merging this PR will not alter performance
|
There was a problem hiding this comment.
Important
Upgrading the msw devDependency to v3 will turn the test_matrix (20) CI job red. The root vitest project loads this v3 copy for the msw suite, and v3 (via @mswjs/interceptors@0.45.7) calls Promise.withResolvers, which does not exist in Node 20. This needs a CI-matrix change (or a Node gate on the msw tests) before merge.
Reviewed changes
mswdevDependency bump^2.15.0→^3.0.2; themsw: ">=2.0.0"peer range is untouched (correctly covers v3), and package source is unchanged.msw-v2alias + second vitest project (vitest.config.ts:42-56) aliasesmsw→msw-v2sopackages/msw/**/*.test.tsalso runs against MSW v2. Verified the alias actually resolves v2 (msw/package.json→2.15.0in themsw-v2project,3.0.2in the root project).listen()option rename toonUnhandledFrame: 'error'in the three msw test files — correct for v3 (v2 ignores the unknown key, so the v2 run stays lenient as described).- Docs note v2/v3 support and document the renamed passthrough option.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — delta since the prior pullfrog review (new commit a2a3c91f):
- Node-version gate on the msw v3 project (
vitest.config.ts:36-43): the root project excludes./packages/msw/**whenNumber.parseInt(process.versions.node) < 22, so on Node 20 only themsw-v2project runs the suite and the v3-onlyPromise.withResolversfailure is avoided.
Verified locally: Node 20.20.2 runs 28 tests (all msw-v2, pass); Node 24 runs 56 tests (v3 + v2, pass). This addresses the Node 20 CI concern raised in the prior review.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
…3cz11 # Conflicts: # packages/msw/package.json # pnpm-lock.yaml
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NNXLdknBGr7KSffPGDLHB9
|
Update: Workers Builds: orpc ran again on the current head, 125071d, and passed in about 3 minutes. The preview deployed. The earlier failure on 80d45a5 was a one-off build problem and needs no action. Original noteWorkers Builds: orpc (the Cloudflare docs deploy) failed on 80d45a5, an earlier commit of this PR. It ran for about 31 minutes and reported no error output to GitHub. A local Generated by Claude Code |

Upgrades the
mswdev dependency of@orpc/experimental-mswto v3 and keeps MSW v2 support tested. Supersedes #2200.Changes
mswdevDependency^2.15.0→^3.0.2. The package source needs no changes:http.all,passthrough,HttpHandler,ResponseResolverInfo,HttpRequestResolverExtrasandPathParamsare unchanged in v3. The existingmsw: ">=2.0.0"peer range already covers v3.listen()optiononUnhandledRequesttoonUnhandledFrameand silently ignores the old name, so the tests were no longer strict about unhandled requests. Switched toonUnhandledFrame: 'error'.msw-v2(npm:msw@^2.15.0) as a devDependency and anmsw-v2vitest project that rerunspackages/msw/**/*.test.tswithmsw/msw/*aliased to it. Both the package source and the tests then load v2. The v2 run is lenient about unhandled requests, since v2 ignoresonUnhandledFrame.Promise.withResolvers, so the v3 run fails on the Node 20 CI job. On Node < 22, the default project excludespackages/msw, and themsw-v2project still runs the full msw suite there.onUnhandledFrame(onUnhandledRequestin v2).Testing
pnpm vitest run packages/msw: 56 tests pass on Node 22 (28 on v3, 28 on v2), and 28 pass on Node 20 (v2 only). A temporary probe test confirmed each project loads the intended msw version (3.0.2 / 2.15.0).pnpm vitest run, roottsc(which covers test files), eslint, sherif andpnpm docs:validateall pass.Notes for users upgrading to MSW v3
v3 requires Node.js 22.12+ and TypeScript 5.9+. It also no longer manages cookies in Node.js, and
request.headers.get('cookie')returnsnull, so acontextoption that reads cookies from the request headers should use thecookiesresolver argument instead.🤖 Generated with Claude Code
https://claude.ai/code/session_01NNXLdknBGr7KSffPGDLHB9