fix(globals): complete Node parity#6853
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughThe changes update runtime exception handle restoration, proxy and Promise behavior, navigator locale reporting, constructor metadata, package resolution, native-module dispatch, and parity test retries for CommonJS-compatible globals tests. ChangesRuntime behavior
Parity harness
Compiler and module resolution
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/perry-runtime/src/value/dyn_index.rs (1)
388-399: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winDispatch Proxies before the Symbol fast path.
For
proxy[symbol] = value,js_dyn_index_setcurrently callsjs_object_set_symbol_propertyand returns beforejs_proxy_setruns, bypassing the Proxysettrap for Symbol keys. Checkjs_proxy_is_proxy(obj)first, mirroring the proxy fast-path behavior used elsewhere.🤖 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 `@crates/perry-runtime/src/value/dyn_index.rs` around lines 388 - 399, Move the js_proxy_is_proxy check in js_dyn_index_set before the Symbol-key branch, so proxy targets—including proxy[symbol] assignments—always dispatch through js_proxy_set before any direct property fast path. Preserve the existing direct js_object_set_symbol_property behavior for non-proxy objects.
🧹 Nitpick comments (1)
crates/perry-parser/src/lib.rs (1)
563-566: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd a regression test for nearest-package precedence.
This correctly prevents a nested
{ "type": "commonjs" }package from falling through to an ancestor ESM package. Add a fixture covering that hierarchy so this compatibility behavior remains protected.🤖 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 `@crates/perry-parser/src/lib.rs` around lines 563 - 566, Add a regression fixture and test for the package-resolution logic around package_json_declares_esm_context, covering an ancestor package declaring ESM and a nearer nested package declaring CommonJS. Assert that the nearest package takes precedence and the nested file is treated as CommonJS.
🤖 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 `@crates/perry-runtime/src/exception.rs`:
- Around line 505-520: The regression test’s NaN-box pattern is being
numerically converted instead of preserving its bit representation. Update the
`_orphaned` initialization in
`js_throw_path_restores_runtime_handles_across_unwound_frames` to construct the
value with `f64::from_bits(...)`; keep the existing tagged payload unchanged.
In `@crates/perry-runtime/src/navigator.rs`:
- Around line 60-68: Update navigator_language to strip POSIX locale modifiers
such as “@...” before converting underscores to hyphens, and validate the
resulting value as a language tag rather than relying only on contains('-').
Preserve the existing LC_ALL/LANG fallback order and en-US default while
rejecting malformed locale values.
---
Outside diff comments:
In `@crates/perry-runtime/src/value/dyn_index.rs`:
- Around line 388-399: Move the js_proxy_is_proxy check in js_dyn_index_set
before the Symbol-key branch, so proxy targets—including proxy[symbol]
assignments—always dispatch through js_proxy_set before any direct property fast
path. Preserve the existing direct js_object_set_symbol_property behavior for
non-proxy objects.
---
Nitpick comments:
In `@crates/perry-parser/src/lib.rs`:
- Around line 563-566: Add a regression fixture and test for the
package-resolution logic around package_json_declares_esm_context, covering an
ancestor package declaring ESM and a nearer nested package declaring CommonJS.
Assert that the nearest package takes precedence and the nested file is treated
as CommonJS.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: aec0e5c8-07bc-42d4-bbbe-1a021155af69
📒 Files selected for processing (12)
crates/perry-codegen/src/nm_install.rscrates/perry-hir/src/analysis/builtins.rscrates/perry-parser/src/lib.rscrates/perry-runtime/src/exception.rscrates/perry-runtime/src/gc/roots.rscrates/perry-runtime/src/gc/roots/runtime_handles.rscrates/perry-runtime/src/navigator.rscrates/perry-runtime/src/object/global_this_tables.rscrates/perry-runtime/src/object/polymorphic_index.rscrates/perry-runtime/src/promise/then.rscrates/perry-runtime/src/value/dyn_index.rsrun_parity_tests.sh
Summary
Complete Node 26.5.0 parity for
node:globals.Changes
node:pathbehavior.[[Set]]and restore runtime handles when exceptions unwind..ctsfiles for both Node and Perry.Related issue
Closes #6780
Test plan
./run_parity_tests.sh --suite node-suite --module globalscargo test -p perry-runtime js_throw_path_restores_runtime_handles_across_unwound_frames --libcargo test -p perry-codegen path_slash_submodules_install_the_path_dispatch_bucket --libbash -n run_parity_tests.shshellcheck run_parity_tests.sh(not installed locally)Checklist
feat:/fix:/docs:/chore:prefix convention used in the logSummary by CodeRabbit
package.jsonscope governs ESM vs CommonJS.[[Set]]semantics.Promise.prototype.thenerrors fornull/undefinedreceivers and aligned the non-callablethenmessage.node:pathsubmodule variants and ensuredEventTarget.lengthresolves to0.navigator.language/navigator.languagesnow reflect system locale settings when available.