Skip to content

Handle urls in import path by making vfs not panic on Url paths#2685

Merged
sheetalkamat merged 3 commits intomainfrom
panicPath
Feb 4, 2026
Merged

Handle urls in import path by making vfs not panic on Url paths#2685
sheetalkamat merged 3 commits intomainfrom
panicPath

Conversation

@sheetalkamat
Copy link
Copy Markdown
Member

Fixes #1905

Copilot AI review requested due to automatic review settings February 4, 2026 22:25
Comment thread internal/vfs/iovfs/iofs.go
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a panic that occurred when the VFS (Virtual File System) encountered URL paths like "https://deno.land/std@0.208.0/path/mod.ts". The TypeScript compiler's module resolver would crash when trying to resolve imports with absolute URLs because the VFS implementation expected only file system paths.

Changes:

  • Modified VFS path handling to recognize and gracefully handle URL paths by detecting negative root lengths and returning the correct positive length
  • Updated iovfs.RootFor to return nil for URL roots instead of attempting to create invalid sub-filesystems
  • Added compiler tests and integration tests to verify URL imports don't cause crashes

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/vfs/internal/internal.go Fixed RootLength to handle negative values (URLs) by using bitwise NOT operation to convert to positive length
internal/vfs/iovfs/iofs.go Added URL detection in RootFor to return nil instead of panicking when trying to create sub-filesystem for URLs
testdata/tests/cases/compiler/importUrl.ts Minimal test case with a URL import to verify no crash occurs
testdata/tests/cases/compiler/importUrlNodeModulesExist.ts Test case with URL import and existing node_modules to verify resolution behavior
internal/project/untitled_test.go Integration test that verifies URL imports work in untitled files without crashing
testdata/baselines/reference/compiler/*.{types,symbols,js,trace.json} Baseline files showing expected behavior: URLs are skipped during module resolution

@sheetalkamat sheetalkamat added this pull request to the merge queue Feb 4, 2026
Merged via the queue into main with commit 72b3f2f Feb 4, 2026
27 checks passed
@sheetalkamat sheetalkamat deleted the panicPath branch February 4, 2026 23:23
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.

panic: vfs: path is not absolute

3 participants