Skip to content

fix(test): pass file:// URL to the ESM resolver in the sync loader#41138

Merged
dgozman merged 2 commits into
microsoft:mainfrom
dgozman:fix-41121
Jun 4, 2026
Merged

fix(test): pass file:// URL to the ESM resolver in the sync loader#41138
dgozman merged 2 commits into
microsoft:mainfrom
dgozman:fix-41121

Conversation

@dgozman

@dgozman dgozman commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fix ESM resolution in the synchronous module customization hooks. These hooks serve both require() and import: require()'s resolver wants an absolute path, while the ESM resolver wants a file:// URL and, on Windows, mistakes an absolute path's drive letter for a URL scheme (Received protocol 'c:'). Pick the form using the import condition.
  • Default all ttest bots to Node 22 (where the sync hooks are used) and keep Node 20 coverage on ubuntu only. The Windows bots previously ran Node 20, so this regression went uncaught.

Fixes #41121

Adds a regression test for ESM projects importing a real relative .js
file, which the resolve hook turns into an absolute path. On Windows the
default ESM resolver rejects it ("Received protocol 'c:'").

The Windows ttest bots ran Node 20, which does not use the synchronous
module customization hooks, so this path was never exercised. Default
all ttest bots to Node 22 and keep Node 20 coverage on ubuntu only.

Refs: microsoft#41121
@github-actions

This comment has been minimized.

The synchronous module customization hooks serve both require() and
import. When resolveHook rewrites a specifier, require()'s resolver
wants an absolute path while the ESM resolver wants a file:// URL and,
on Windows, mistakes an absolute path's drive letter for a URL scheme
("Received protocol 'c:'"). Pick the form using the `import` condition.

Remove the temporary regression test; the bumped Windows + Node 22 ttest
bots already cover this path.

Fixes: microsoft#41121
@dgozman dgozman changed the title test(loader): cover esm relative .js import on windows + node 22 bots fix(test): pass file:// URL to the ESM resolver in the sync loader Jun 4, 2026
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Test results for "MCP"

7230 passed, 1103 skipped


Merge workflow run.

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

1 flaky ⚠️ [firefox-page] › page/page-emulate-media.spec.ts:144 › should keep reduced motion and color emulation after reload `@firefox-ubuntu-22.04-node20`

39544 passed, 771 skipped


Merge workflow run.

@dgozman dgozman merged commit 78c9dfd into microsoft:main Jun 4, 2026
68 of 69 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.

[Regression]: ESM projects with playwright do not work on Windows

2 participants