Skip to content

chore(msw): upgrade MSW to v3 while keeping v2 support - #2203

Merged
dinwwwh merged 6 commits into
mainfrom
claude/festive-cori-p3cz11
Oct 10, 2026
Merged

dinwwwh merged 6 commits into
mainfrom
claude/festive-cori-p3cz11

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Upgrades the msw dev dependency of @orpc/experimental-msw to v3 and keeps MSW v2 support tested. Supersedes #2200.

Changes

  • Upgrade: msw devDependency ^2.15.0 → ^3.0.2. The package source needs no changes: http.all, passthrough, HttpHandler, ResponseResolverInfo, HttpRequestResolverExtras and PathParams are unchanged in v3. The existing msw: ">=2.0.0" peer range already covers v3.
  • Tests: v3 renamed the listen() option onUnhandledRequest to onUnhandledFrame and silently ignores the old name, so the tests were no longer strict about unhandled requests. Switched to onUnhandledFrame: 'error'.
  • v2 test run: added msw-v2 (npm:msw@^2.15.0) as a devDependency and an msw-v2 vitest project that reruns packages/msw/**/*.test.ts with msw / msw/* aliased to it. Both the package source and the tests then load v2. The v2 run is lenient about unhandled requests, since v2 ignores onUnhandledFrame.
  • Node 20: MSW v3 requires Node.js 22.12+. Its interceptors call Promise.withResolvers, so the v3 run fails on the Node 20 CI job. On Node < 22, the default project excludes packages/msw, and the msw-v2 project still runs the full msw suite there.
  • Docs: the MSW integration page notes that both MSW v2 and v3 are supported, and the passthrough section names onUnhandledFrame (onUnhandledRequest in 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).
  • Full pnpm vitest run, root tsc (which covers test files), eslint, sherif and pnpm docs:validate all 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') returns null, so a context option that reads cookies from the request headers should use the cookies resolver argument instead.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NNXLdknBGr7KSffPGDLHB9

- 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
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

codecov Bot commented Oct 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@pkg-pr-new

pkg-pr-new Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
More templates

@orpc/ai-sdk

npm i https://pkg.pr.new/@orpc/ai-sdk@2203

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@2203

@orpc/bun

npm i https://pkg.pr.new/@orpc/bun@2203

@orpc/client

npm i https://pkg.pr.new/@orpc/client@2203

@orpc/cloudflare

npm i https://pkg.pr.new/@orpc/cloudflare@2203

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@2203

@orpc/experimental-effect

npm i https://pkg.pr.new/@orpc/experimental-effect@2203

@orpc/evlog

npm i https://pkg.pr.new/@orpc/evlog@2203

@orpc/hibernation

npm i https://pkg.pr.new/@orpc/hibernation@2203

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@2203

@orpc/experimental-lock

npm i https://pkg.pr.new/@orpc/experimental-lock@2203

@orpc/experimental-msw

npm i https://pkg.pr.new/@orpc/experimental-msw@2203

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@2203

@orpc/next

npm i https://pkg.pr.new/@orpc/next@2203

@orpc/node

npm i https://pkg.pr.new/@orpc/node@2203

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@2203

@orpc/opentelemetry

npm i https://pkg.pr.new/@orpc/opentelemetry@2203

@orpc/pinia-colada

npm i https://pkg.pr.new/@orpc/pinia-colada@2203

@orpc/pino

npm i https://pkg.pr.new/@orpc/pino@2203

@orpc/publisher

npm i https://pkg.pr.new/@orpc/publisher@2203

@orpc/ratelimit

npm i https://pkg.pr.new/@orpc/ratelimit@2203

@orpc/server

npm i https://pkg.pr.new/@orpc/server@2203

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@2203

@orpc/swr

npm i https://pkg.pr.new/@orpc/swr@2203

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@2203

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@2203

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@2203

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@2203

commit: 125071d

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
@codspeed

codspeed Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ 5 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 28 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing claude/festive-cori-p3cz11 (125071d) with main (d1b6ad0)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • msw devDependency bump ^2.15.0 → ^3.0.2; the msw: ">=2.0.0" peer range is untouched (correctly covers v3), and package source is unchanged.
  • msw-v2 alias + second vitest project (vitest.config.ts:42-56) aliases msw → msw-v2 so packages/msw/**/*.test.ts also runs against MSW v2. Verified the alias actually resolves v2 (msw/package.json → 2.15.0 in the msw-v2 project, 3.0.2 in the root project).
  • listen() option rename to onUnhandledFrame: '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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Comment thread packages/msw/package.json

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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/** when Number.parseInt(process.versions.node) < 22, so on Node 20 only the msw-v2 project runs the suite and the v3-only Promise.withResolvers failure 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.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

…3cz11

# Conflicts:
#	packages/msw/package.json
#	pnpm-lock.yaml

dinwwwh commented Oct 10, 2026 •

Copy link
Copy Markdown
Member Author

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 note

Workers 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 blume build compiled all the content and rendered /docs/integrations/msw and its OG image. pnpm docs:validate (blume validate --strict) also passes. Nothing pointed to this PR's docs change, which is an :::info block and a link on the MSW integration page.


Generated by Claude Code

@dinwwwh
dinwwwh merged commit 4e67f77 into main Oct 10, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants