Skip to content

fix: Module injection silently fails on Windows - #58

Merged
timfish merged 1 commit into
mainfrom
fix/windows-resolve-file-url
Sep 24, 2026
Merged

timfish merged 1 commit into
mainfrom
fix/windows-resolve-file-url

Conversation

@timfish

@timfish timfish commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

On Windows the resolve hook never matched any module: resolveFromURL passed a file:// URL to module-details-from-path, which splits on path.sep, so node_modules was never found and no transformer was registered. This converts the URL with fileURLToPath first (guarding non-file URLs) and uses the native basedir directly, which fixes the sync Module.registerHooks() path on Node 24.13+ and keeps the async path working.

The new tests resolve a Windows-style file URL and a node: URL. module-details-from-path reads path.sep once when it loads, so the Windows-style test also passes against the old code on POSIX. It only catches this bug on a Windows runner.

@timfish
timfish force-pushed the fix/windows-resolve-file-url branch from a229a6d to efa372f Compare September 24, 2026 12:08
@timfish timfish changed the title Convert file URL to a path before module-details-from-path so Windows resolves modules Convert file URL to a path before module-details-from-path so Windows resolves modules Sep 24, 2026
@timfish
timfish force-pushed the fix/windows-resolve-file-url branch from 6fc7b5d to ae23710 Compare September 24, 2026 12:13
@timfish
timfish force-pushed the fix/windows-resolve-file-url branch from ae23710 to 9fa75a4 Compare September 24, 2026 12:18
@timfish timfish changed the title Convert file URL to a path before module-details-from-path so Windows resolves modules fix: Module injection silently fails on Windows Sep 24, 2026
@timfish
timfish merged commit c0041a5 into main Sep 24, 2026
10 checks passed
@timfish
timfish deleted the fix/windows-resolve-file-url branch September 24, 2026 14:37
isaacs pushed a commit to getsentry/sentry-javascript that referenced this pull request Sep 24, 2026
)

- Fixes #24695

Bumps `@apm-js-collab/tracing-hooks` to 0.13.3 in
`@sentry/server-runtime-injection` to pick up the Windows fix for
orchestrion diagnostics-channel injection
(apm-js-collab/tracing-hooks#58). Without it, sync
`Module.registerHooks()` instrumentation silently no-ops on Windows and
Node 24.13+.
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