Skip to content

Fix backslashes in async bundle paths on Windows - #1938

Merged
robhogan merged 1 commit into
mainfrom
pr1938
Sep 29, 2026
Merged

robhogan merged 1 commit into
mainfrom
pr1938

Conversation

@robhogan

@robhogan robhogan commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

With includeAsyncPaths, each __d(...) call carries a server-relative URL per async dependency, which the client uses to fetch the split bundle. On Windows that URL is built with system path separators, so it comes out as /src\bar.bundle?modulesOnly=true&runModule=false. Metro parses bundle URLs as posix paths:

const pathname = searchParams.get('bundleEntry') || requestPathname || '';
const platform =
searchParams.get('platform') ||
parsePlatformFilePath(pathname, platforms).platform;
const bundleType = getBundleType(path.extname(pathname).substring(1));
const {pathname: sourceMapPathname} = new URL(
pathname.replace(/\.(bundle|delta)$/, '.map'),

This normalises the separators to / on every platform. No change on posix.

Changelog:

 - **[Fix]**: Fix backslashes in async bundle paths on Windows (`includeAsyncPaths`)

Test plan:
Removes js-test.js from the Windows skip list. Its async paths tests assert forward-slash URLs from Windows-style inputs, and failed on Windows CI before this:

- "paths":{"1":"/../bar.bundle?param1=true&param2=1234&modulesOnly=true&runModule=false"}
+ "paths":{"1":"/..\\bar.bundle?param1=true&param2=1234&modulesOnly=true&runModule=false"}

Windows CI on this PR is green.

@robhogan
robhogan added this pull request to stack #1940 September 17, 2026 11:47
@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 Sep 17, 2026
Base automatically changed from pr1937 to main September 29, 2026 17:29
Summary:
With `includeAsyncPaths`, Metro writes a server-relative URL for each async dependency into the `paths` argument of `__d(...)`, which the client uses to fetch the split bundle. `getDefaultAsyncDependencyPath` builds that URL with `path.relative` and `path.join`, and never converts separators, so on Windows a dependency at `C:\root\src\bar.js` under server root `C:\root` produces:

```
/src\bar.bundle?modulesOnly=true&runModule=false
```

This is a URL, and Metro's own parsing of bundle URLs treats the pathname as posix (`split('/')` in `parseBundleOptionsFromBundleRequestUrl`), so it should be `/src/bar.bundle?...` on every platform. This passes the joined path through `normalizePathSeparatorsToPosix`, already used in the same file for module debug names. No change on posix.

Changelog: [Fix] Fix backslashes in async bundle paths on Windows (`includeAsyncPaths`)

Test Plan:
Removes `js-test.js` from the Windows skip list. Its three async `paths` tests already assert forward-slash URLs from Windows-style inputs.

Before this change, on Windows CI:

```
  ✕ includes the paths of async dependencies when requested
  - "paths":{"1":"/../bar.bundle?param1=true&param2=1234&modulesOnly=true&runModule=false"}
  + "paths":{"1":"/..\\bar.bundle?param1=true&param2=1234&modulesOnly=true&runModule=false"}
  ✕ async bundle paths override modulesOnly and runModule
  ✕ passes a paths object (not the id array) for async dependencies
```

After, `yarn jest packages/metro/src/DeltaBundler` passes, and Windows CI on this PR is green for `js-test.js`.
@robhogan
robhogan marked this pull request as ready for review September 29, 2026 17:30
@robhogan
robhogan requested a balanced review from Copilot September 29, 2026 17:30

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 focused fix preserves POSIX behavior and is covered by the re-enabled Windows tests.

Review effort: Balanced
Findings: None

What changed in this PR

Normalizes async bundle URLs to POSIX separators on Windows.

Changes:

  • Converts generated bundle paths to forward slashes.
  • Re-enables serializer tests on Windows.
File Description
scripts/​jestFilter.js Removes the resolved Windows test exclusion.
packages/​metro/​src/​DeltaBundler/​Serializers/​helpers/​js.js Normalizes async bundle URL separators.

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

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Sep 29, 2026
@robhogan
robhogan merged commit d52ee79 into main Sep 29, 2026
16 checks passed
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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants