Skip to content

Fix HmrServer crash when entry point uses virtual URL prefix - #2017

Open
robhogan wants to merge 1 commit into
pr2014from
pr2016
Open

robhogan wants to merge 1 commit into
pr2014from
pr2016

Conversation

@robhogan

@robhogan robhogan commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Recreating #1709 / D104223071 (@motiz88) for GH first without a diff attachment

D102004228 added support for serving bundles from Server with the handling [metro-watchFolders]/<N>/... or [metro-project]/... virtual URL prefixes, but did not add the same support in HmrServer.

Here, HmrServer constructs its own ProjectRouteMap to match Server's behaviour exactly.

Changelog:

  • [Fix]: Prevent HMR crash on [metro-watchFolders] or [metro-project] URLs

Test plan:
See D104223071

@robhogan
robhogan added this pull request to stack #2016 October 3, 2026 22:02
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 3, 2026
@robhogan
robhogan requested review from huntie and vzaidman and a balanced review from Copilot October 3, 2026 22:08
@robhogan
robhogan marked this pull request as ready for review October 3, 2026 22:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

馃煛 Changes recommended

The new tests use unnormalized filesystem paths and will fail on Windows.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds virtual URL prefix support to HMR entry-point resolution, matching Metro Server behavior.

Changes:

  • Resolves [metro-project] and [metro-watchFolders] HMR paths.
  • Reuses ProjectRouteMap for server-root handling.
  • Adds coverage for both virtual prefixes.
File Description
packages/鈥媘etro/鈥媠rc/鈥婬mrServer.js Integrates virtual route mapping into HMR.
packages/鈥媘etro/鈥媠rc/鈥媉_tests__/鈥婬mrServer-test.js Tests virtual-prefix entry points.

馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/metro/src/__tests__/HmrServer-test.js Outdated
*Recreating #1709 / [D104223071](https://www.internalfb.com/diff/D104223071) (@motiz88) for GH first without a diff attachment*

D102004228 added support for serving bundles from `Server` with the handling `[metro-watchFolders]/<N>/...` or `[metro-project]/...` virtual URL prefixes, but did not add the same support in `HmrServer`.

Here, `HmrServer` constructs its own `ProjectRouteMap` to match `Server`'s behaviour exactly.

Changelog:

* **[Fix]:** Prevent HMR crash on `[metro-watchFolders]` or `[metro-project]` URLs

Test plan:
See [D104223071](https://www.internalfb.com/diff/D104223071)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

馃煝 Approval recommended

The implementation matches existing Server behavior and covers both supported virtual prefixes with focused tests.

Review effort: Balanced
Findings: None

Resolved since last review (1)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants