Skip to content

fix(plugins): convert plugin path to file:// URL for ESM import on Windows#3967

Closed
Chen-538 wants to merge 1 commit into
jo-inc:masterfrom
Chen-538:fix/windows-plugin-loader-esm-url
Closed

fix(plugins): convert plugin path to file:// URL for ESM import on Windows#3967
Chen-538 wants to merge 1 commit into
jo-inc:masterfrom
Chen-538:fix/windows-plugin-loader-esm-url

Conversation

@Chen-538
Copy link
Copy Markdown
Contributor

Summary

On Windows, npm start fails to load any plugin with:

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'

lib/plugins.js passes a raw absolute path (e.g. C:\...\plugins\persistence\index.js) to await import(...). Node's ESM loader interprets the drive letter as a URL scheme and rejects it. POSIX absolute paths (/...) happen to work, which masked the issue.

Fix: convert the path with pathToFileURL(indexPath).href so the loader always receives a valid file:// URL.

Repro

  1. Clone on Windows, npm install && npm start
  2. Server logs plugin load failed for persistence, vnc, youtube

After this PR

All three plugins load cleanly on Windows. POSIX behavior is unchanged — Node accepts both absolute paths and file:// URLs equivalently for dynamic import().

Test plan

  • npm test plugin and unit suites pass (659/660; one remaining failure is an unrelated pre-existing Windows test expecting camoufox-bin without the .exe suffix)
  • Manual: POST /tabs against example.com succeeds end-to-end on Windows

…ndows

Dynamic `import(indexPath)` failed on Windows with
`ERR_UNSUPPORTED_ESM_URL_SCHEME` because Node's ESM loader treats the
drive letter (`c:`) as a URL protocol. POSIX absolute paths happened to
work, masking the issue.

Use `pathToFileURL(indexPath).href` so the loader receives a valid
`file://` URL on all platforms. Behavior on POSIX is unchanged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@skyfallsin
Copy link
Copy Markdown
Contributor

Shipped in v1.11 — thank you!

We merged the Windows ESM plugin loading fix using pathToFileURL(...).href, so plugins import correctly from Windows filesystem paths.

Release notes: https://github.com/jo-inc/camofox-browser/releases/tag/v1.11.0
Latest patch: https://github.com/jo-inc/camofox-browser/releases/tag/v1.11.1

@skyfallsin
Copy link
Copy Markdown
Contributor

Closing since this shipped via #4150 in v1.11.

@skyfallsin skyfallsin closed this May 24, 2026
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