Consolidate node fs/path/types helpers#32021
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughRefactors Node filesystem and path runtime: shared UID/GID and timestamp argument parsers, centralized Linux/Android copy_file_range with EINTR policy and fallbacks, unified utimes/lutimes helper, path-scanning core for basename/extname, macro-generated enum labels, a type-detection simplification, and added tests. ChangesNode Runtime Consolidation
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
Updated 5:05 AM PT - Jun 10th, 2026
❌ @robobun, your commit d9ec253 has some failures in 🧪 To try this PR locally: bunx bun-pr 32021That installs a local version of the PR into your bun-32021 --bun |
|
@robobun adopt |
|
Adopted. I audited the full diff against main for behavior changes and found none. The basename/extname/parse merges keep the exact loop bounds and drive-letter gating of the split posix/win32 versions. Verified on a local debug build: the node path suites, upstream test-path-, fs.test.ts, cp.test.ts, promises.test.js, and test-fs-{utimes,chown-type-check,copyfile} all pass. Added CI state: in the latest build (61738), every job that executed passed on all platforms (284 green, zero test failures). The build is red only because two darwin-14-aarch64 test shards expired in the agent queue before running, twice in a row, same as an earlier debian shard. This needs either a job retry in the Buildkite UI or a merge decision on the green lanes; another push from me would just re-enter the same starved queues. |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/runtime/node/node_fs.rs (1)
8083-8142:⚠️ Potential issue | 🟠 Major | ⚡ Quick win
lutimes()now reports the wrong syscall on Windows failures.
utimes_with()hardcodessys::Tag::utime, andlutimes()now funnels through it. On Windows that changes the exposederr.syscallfromlutimetoutimeforfs.lutimes()failures.Suggested fix
fn utimes_with( &mut self, args: &args::Utimes, + syscall: sys::Tag, #[cfg(windows)] uv_utime: unsafe extern "C" fn( *mut uv::Loop, *mut uv::fs_t, *const core::ffi::c_char, @@ return if let Some(errno) = rc.errno() { Err(sys::Error { errno, - syscall: sys::Tag::utime, + syscall, path: args.path.slice().into(), ..Default::default() }) } else { Ok(()) @@ pub fn utimes(&mut self, args: &args::Utimes, _: Flavor) -> Maybe<ret::Utimes> { #[cfg(windows)] - return self.utimes_with(args, uv::uv_fs_utime); + return self.utimes_with(args, sys::Tag::utime, uv::uv_fs_utime); #[cfg(not(windows))] - self.utimes_with(args, Syscall::utimens) + self.utimes_with(args, sys::Tag::utime, Syscall::utimens) } pub fn lutimes(&mut self, args: &args::Lutimes, _: Flavor) -> Maybe<ret::Lutimes> { #[cfg(windows)] - return self.utimes_with(args, uv::uv_fs_lutime); + return self.utimes_with(args, sys::Tag::lutime, uv::uv_fs_lutime); #[cfg(not(windows))] - self.utimes_with(args, Syscall::lutimens) + self.utimes_with(args, sys::Tag::lutime, Syscall::lutimens) }As per coding guidelines: "Node.js compatibility: match Node's full error contract including error code, constructor class, message text, properties, and check ordering."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/runtime/node/node_fs.rs` around lines 8083 - 8142, The Windows branch in utimes_with() always sets sys::Tag::utime, so when lutimes() calls utimes_with() failures report the wrong syscall; update utimes_with() to accept an explicit sys::Tag (or a boolean flag) and use that tag when constructing the Error (i.e., pass sys::Tag::lutime from lutimes() and sys::Tag::utime from utimes()), or alternatively detect which wrapper called it and set errno.syscall accordingly; change the signatures/call sites (utimes(), lutimes(), and utimes_with()) to thread the correct tag through so errors on Windows report sys::Tag::lutime for lutimes() failures.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/runtime/node/node_fs.rs`:
- Around line 8083-8142: The Windows branch in utimes_with() always sets
sys::Tag::utime, so when lutimes() calls utimes_with() failures report the wrong
syscall; update utimes_with() to accept an explicit sys::Tag (or a boolean flag)
and use that tag when constructing the Error (i.e., pass sys::Tag::lutime from
lutimes() and sys::Tag::utime from utimes()), or alternatively detect which
wrapper called it and set errno.syscall accordingly; change the signatures/call
sites (utimes(), lutimes(), and utimes_with()) to thread the correct tag through
so errors on Windows report sys::Tag::lutime for lutimes() failures.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: ef6ee141-6998-469a-861e-af590e172bf8
📒 Files selected for processing (3)
src/runtime/node/node_fs.rssrc/runtime/node/path.rssrc/runtime/node/types.rs
|
On the CodeRabbit finding that bun/src/runtime/node/node_fs.rs Lines 8157 to 8163 in 09703da
That divergence from Node's error contract is real but pre-existing and cross-platform, and fixing it here would contradict this PR's zero-behavior-change contract. Tracked in #32047. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/js/node/fs/fs-chown-utimes.test.ts`:
- Line 10: The test suite describe blocks for "chown/fchown/lchown argument
validation" (and the other describe at the same file) should be switched to
concurrent execution to speed up tests: replace describe("chown/fchown/lchown
argument validation", ...) with describe.concurrent("chown/fchown/lchown
argument validation", ...) and do the same for the second describe block
referenced in the comment so both describe blocks run tests in parallel safely
(each test already uses tmpdirSync()).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1057555e-b5da-443a-a082-55d9fb630623
📒 Files selected for processing (1)
test/js/node/fs/fs-chown-utimes.test.ts
fs.lchown is a TODO stub on Windows (#32050); argument validation still throws before the stub, so those assertions keep running everywhere.
What this does
Dedupes repeated argument-conversion and error-path blocks in
node_fs.rsand removes dead helpers in nodepath/types. Net −500 lines.Split from #31912 (whole-repo simplification pass; closing that PR in favor of module-scoped splits). This PR only moves and removes code — zero intended behavior change. Verified there by a per-file behavioral-equivalence audit and full CI; verified here by a standalone full-workspace compile check.
Tests
test/js/node/fs/fs-chown-utimes.test.tspins the consolidated surface: chown/fchown/lchown must validate uid and gid identically and name the failing argument itself, utimes/futimes/lutimes likewise for atime/mtime, and utimesSync must follow symlinks while lutimesSync must not (the dispatch the mergedutimes_withpreserves). Because this PR intends zero behavior change, these tests pass before and after the refactor by design; they guard the shared readers against future drift. A test that fails on main cannot exist for this PR: any such failure would mean the consolidation changed observable behavior, which is the one outcome it must not have. The correctness argument is the behavioral-equivalence audit plus the full existing suite passing on both sides, not a fail-before proof. The wider surface is already covered by the existing basename/extname/parse tables, fs.test.ts, cp.test.ts, and the ported Node tests, all verified locally against this branch.