Skip to content

fix(module): end drive root candidates with a separator to stop a VFS panic - #1007

Merged
camc314 merged 5 commits into
oxc-project:mainfrom
magurotuna:fix/type-root-drive-root-candidate
Nov 20, 2026
Merged

camc314 merged 5 commits into
oxc-project:mainfrom
magurotuna:fix/type-root-drive-root-candidate

Conversation

@magurotuna

@magurotuna magurotuna commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

A type reference or a relative import whose name is only a drive root panicked:

/// <reference types="C:" />
import "C:";

The resolver built the candidate C: and probed C:.d.ts. That is not an absolute path, so the VFS panicked with vfs: path "C:.d.ts" is not absolute. The panic needs the drive to exist (I reproduced it with an in-memory file system). Without the drive, tsrs -p --traceResolution printed 'C:' where tsgo prints 'C:/'.

Go adds the root separator when it builds the candidate (ensureRootedPathRootSeparator). resolve_path_for_module, normalize_path_for_cjs_resolution, and resolution_candidate_from_directory_path (the type root candidates from #1009) now do the same, with the existing port of that function.

Tests: resolver_drive_root_test (expected traces from the pinned Go resolver) and the type-reference-drive-root regression.

AI assistance: written with Claude Code.

â€Ķ panic

Port Go `ensureRootedPathRootSeparator` (`rooted_path.go:65`) into
`resolve_path_for_module` and `normalize_path_for_cjs_resolution`. Go
builds these candidates with `RootedDirectoryPath.ResolveFile` and
`ResolveDirectory` (`rooted_path.go:727`), which end a path that is only a
root with a separator. `normalize_path` keeps `C:`, as Go `NormalizePath`
does, so it stays unchanged.

A type reference or a relative import whose name is only a drive root,
such as `C:`, gave the candidate `C:`. The file probe `C:.d.ts` is not an
absolute path, so the VFS panicked when the drive existed. Without the
drive, `tsrs -p` did not panic, but its resolution trace printed `'C:'`
where tsgo prints `'C:/'`.
@codspeed

codspeed Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠ïļ 4 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 8 untouched benchmarks
âĐ 8 skipped benchmarks1


Comparing magurotuna:fix/type-root-drive-root-candidate (d16fae1) with main (2dc8ddb)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. â†Đ

@magurotuna
magurotuna marked this pull request as ready for review November 17, 2026 08:24
@camc314
camc314 added this pull request to the merge queue Nov 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 18, 2026
@camc314
camc314 enabled auto-merge November 18, 2026 13:27
camc314 and others added 3 commits November 19, 2026 11:59
â€Ķoot-candidate

# Conflicts:
#	docs/COMPATIBILITY.md
oxc-project#1009 added `resolution_candidate_from_directory_path` for the type root
lookups. It did not use `resolve_path_for_module`, so the type root
candidate for the name `C:` was `C:` again, and the file probe `C:.d.ts`
panicked (`resolver_drive_root_test`). Go `ResolveFile` and
`ResolveDirectory` keep the root separator, so add it there too.

AI assistance: written with Claude Code.
@camc314
camc314 added this pull request to the merge queue Nov 20, 2026
Merged via the queue into oxc-project:main with commit 312f8ca Nov 20, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants