Skip to content

Fix panic when require.resolve options.paths contains non-absolute paths - #32680

Closed
robobun wants to merge 1 commit into
mainfrom
farm/777f74d0/fix-require-paths-non-absolute
Closed

robobun wants to merge 1 commit into
mainfrom
farm/777f74d0/fix-require-paths-non-absolute

Fix panic when require.resolve options.paths contains non-absolute paths

fa253d5
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jun 24, 2026 in 19m 47s

Code review found 1 important issue

Found 2 candidates, confirmed 1. See review comments for details.

Details

Severity Count
🔴 Important 1
🟡 Nit 0
🟣 Pre-existing 0
Severity File:Line Issue
🔴 Important src/resolver/resolver.rs:2095-2107 Panic still reachable on POSIX with Windows-style drive paths in options.paths

Annotations

Check failure on line 2107 in src/resolver/resolver.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

Panic still reachable on POSIX with Windows-style drive paths in options.paths

The guard uses native `bun_paths::is_absolute` (POSIX: leading `/` only), but the else branch joins via `abs_buf_checked`, which uses `platform::Loose` semantics — Loose treats Windows drive paths like `C:/foo` as absolute on any host and replaces the cwd base, so the joined result is still `C:/foo`, which then fails the native `assert!(bun_paths::is_absolute(...))` in `dir_info_cached_maybe_log` (resolver.rs:4203). On Linux/macOS, `require.resolve("pkg", { paths: ["C:/foo"] })` (or `"C:\\foo"`)