Skip to content

fix: add handler to the "request:match" event - #2834

Merged
kettanaito merged 1 commit into
mainfrom
fix/request-match-handler
Nov 10, 2026
Merged

kettanaito merged 1 commit into
mainfrom
fix/request-match-handler

Conversation

@kettanaito

Copy link
Copy Markdown
Member

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The request:match event now includes the matched RequestHandler alongside the request ID and request. Runtime and type tests verify the event payload for matching and passthrough cases, and for Node and browser listeners.

Changes: Request Match Event

Layer / File(s) Summary
Event payload and emission
src/core/experimental/frames/http-frame.ts
A new RequestMatchEvent carries the request ID, request, and matched handler. HttpNetworkFrame emits it for request:match.
Runtime and type validation
src/core/experimental/frames/http-frame.test.ts, test/msw-api/setup-server/life-cycle-events/on.node.test.ts, test/typings/life-cycle-events.test-d.ts
Runtime tests assert that request:match includes the registered handler. Type tests assert that Node and browser listener arguments include a RequestHandler.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Merge Risk: Minimal · up to a07dc

The matched handler reaches lifecycle listeners. The reported Node 26 test failure still needs investigation.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly describes the main change: adding the matched handler to the request:match event.
Description check Passed The description references issue #2833, which requests adding the matched handler to the request:match event.
Linked Issues check Passed Issue #2833 requires request:match to expose the matched handler with requestId and request. HttpNetworkFrame.resolve now emits RequestMatchEvent with all three fields. Runtime tests assert …
Out of Scope Changes check Passed The source change implements issue #2833. The runtime and type-test changes verify the new event payload. No unrelated changes appear in the pull request diff.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

Issue #2833 requires request:match to expose the matched handler with requestId and request. HttpNetworkFrame.resolve now emits RequestMatchEvent with all three fields. Runtime tests assert the handler for matched responses and passthroughs, and type tests cover Node and browser listeners.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 4 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the match event’s new field,
The handler joins the request it helped yield.
Node tests nod, browser types agree,
The event now carries all three.
I hop away, content with the key.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9159a722-372d-45fc-a578-f01e3d12df9f
Commits

Reviewing files that changed from the base of the PR and between 9bbfe99 and a07dc88.

Files selected for processing: 4

  • src/core/experimental/frames/http-frame.test.ts
  • src/core/experimental/frames/http-frame.ts
  • test/msw-api/setup-server/life-cycle-events/on.node.test.ts
  • test/typings/life-cycle-events.test-d.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@kettanaito
kettanaito merged commit 8719ce2 into main Nov 10, 2026
11 of 12 checks passed
@kettanaito
kettanaito deleted the fix/request-match-handler branch November 10, 2026 11:38
@kettanaito

Copy link
Copy Markdown
Member Author

Released: v3.0.5 🎉

This has been released in v3.0.5.

Get these changes by running the following command:

npm i msw@latest

Predictable release automation by Release.

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.

Expose the matched handler on the request:match event

1 participant