Skip to content

fix(node): propagate fs path mutator errors#3490

Merged
proggeramlug merged 4 commits into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-fs-error-propagation
May 31, 2026
Merged

fix(node): propagate fs path mutator errors#3490
proggeramlug merged 4 commits into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-fs-error-propagation

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Linked issues

Closes #2733
Closes #2735
Closes #2737
Closes #2738
Closes #2740

Summary

This PR fixes a focused node:fs error-propagation cluster for deterministic path and path-pair filesystem failures:

  • readlink now throws/callbacks/rejects real fs errors instead of returning an empty target.
  • rename, copyFile, link, and symlink now preserve Node-style Error fields across sync, callback, and node:fs/promises surfaces.
  • Two-path syscall errors now expose err.dest alongside err.code, err.syscall, and err.path.
  • The fs parity gap docs and fs suite status are updated for the APIs covered here.

Why these were batched

These issues share the same runtime path: sentinel-returning fs mutators, callback wrappers that previously reported success after failed syscalls, and fs/promises thunks that need to reject with the same error objects. Batching them keeps the side-table/error-object changes and parity fixture in one coherent fs PR.

Tests added

  • Added test-parity/node-suite/fs/path-mutator-errors.ts, covering sync, callback, and node:fs/promises behavior for missing paths, invalid readlink targets, missing destination parents, COPYFILE_EXCL, existing symlink destinations, and success sanity checks.

Verification

  • TMPDIR="$PWD/target/tmp" PATH=/home/github-runner/actions-runner/externals/node24/bin:$PATH ./run_parity_tests.sh --suite node-suite --module fs --filter path-mutator-errors - pass
  • TMPDIR="$PWD/target/tmp" PATH=/home/github-runner/actions-runner/externals/node24/bin:$PATH ./run_parity_tests.sh --suite node-suite --module fs - 126 pass, 0 fail
  • TMPDIR="$PWD/target/tmp" PATH=/home/github-runner/actions-runner/externals/node24/bin:$PATH ./run_parity_tests.sh --suite node-suite --module fs-promises - 62 pass, 0 fail
  • TMPDIR="$PWD/target/tmp" CARGO_BUILD_JOBS=1 RUSTC_WRAPPER= cargo check -p perry-runtime -p perry-codegen -p perry-api-manifest - pass with existing warnings
  • TMPDIR="$PWD/target/tmp" CARGO_BUILD_JOBS=1 RUSTC_WRAPPER= cargo test -p perry-runtime fs:: - 2 pass, 0 fail
  • cargo fmt --all -- --check - pass
  • git diff --check HEAD - pass
  • ./scripts/check_file_size.sh - pass

Known limitations

  • The new fixture pins stable Error fields, not full platform-specific message text or numeric errno values.
  • Broader fs error parity for unrelated APIs remains tracked separately.

Non-goals

  • No changes to fs.watch, FileHandle semantics, stream behavior, or callback scheduling semantics.

proggeramlug and others added 3 commits May 31, 2026 08:25
# Conflicts:
#	crates/perry-runtime/src/fs/callbacks.rs
#	crates/perry-runtime/src/fs/mod.rs
#	crates/perry-runtime/src/node_submodules/diagnostics.rs
#	crates/perry-runtime/src/node_submodules/fs_promises.rs
#	crates/perry-runtime/src/object/field_get_set.rs
#	docs/runtime-parity-gaps.md
@proggeramlug proggeramlug merged commit 4a64ca2 into PerryTS:main May 31, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment