Skip to content

fix(async_hooks): validate hooks and forward ALS args#3457

Merged
proggeramlug merged 7 commits into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-async-hooks-createhook-als-args
May 31, 2026
Merged

fix(async_hooks): validate hooks and forward ALS args#3457
proggeramlug merged 7 commits into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-async-hooks-createhook-als-args

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Summary

  • validate async_hooks.createHook nullish options and present non-callable hook members with Node-compatible TypeError/ERR_ASYNC_CALLBACK behavior
  • thread AsyncLocalStorage run()/exit() rest args through native lowering and call callbacks with the forwarded argument array
  • add async_hooks parity fixtures for createHook validation and ALS rest argument forwarding

Tests

  • cargo fmt --all -- --check
  • git diff --check
  • RUSTC_WRAPPER= cargo test -p perry-runtime async_hooks --lib -- --test-threads=1
  • RUSTC_WRAPPER= cargo test -p perry-codegen --test manifest_consistency
  • RUSTC_WRAPPER= CARGO_TARGET_DIR=/tmp/perry-node-compat-3-target cargo build --release -p perry -p perry-runtime -p perry-stdlib
  • RUSTC_WRAPPER= CARGO_TARGET_DIR=/tmp/perry-node-compat-3-target PERRY_ALLOW_UNIMPLEMENTED=1 /tmp/perry-node-compat-3-target/release/perry test-parity/node-suite/async_hooks/create-hook-validation.ts -o /tmp/perry_create_hook_validation && diff -u <(node --input-type=module < test-parity/node-suite/async_hooks/create-hook-validation.ts) <(/tmp/perry_create_hook_validation)
  • RUSTC_WRAPPER= CARGO_TARGET_DIR=/tmp/perry-node-compat-3-target PERRY_ALLOW_UNIMPLEMENTED=1 /tmp/perry-node-compat-3-target/release/perry test-parity/node-suite/async_hooks/als-run-exit-callback-validation.ts -o /tmp/perry_als_run_exit_validation && diff -u <(node --input-type=module < test-parity/node-suite/async_hooks/als-run-exit-callback-validation.ts) <(/tmp/perry_als_run_exit_validation)
  • ./scripts/check_file_size.sh (fails on current base: crates/perry-codegen/src/runtime_decls/strings.rs is 2001 lines; this PR does not modify that file)

@andrewtdiz
Copy link
Copy Markdown
Contributor Author

Fixed the mainline merge conflict, lint failure, and API docs drift on this branch.

  • Merged current origin/main through 02b4038a9.
  • Combined the branch's async_hooks / ALS forwarding work with the mainline AsyncResource validation changes.
  • Regenerated API manifest docs after the merge.
  • Removed stale merge helper functions that were tripping the branch lint check.
  • Local checks passed: cargo fmt --all -- --check, git diff --check, ./scripts/check_file_size.sh, RUST_TEST_THREADS=1 CARGO_TARGET_DIR=/root/perry/target cargo test -p perry-runtime async_hooks, and CARGO_TARGET_DIR=/root/perry/target cargo test -p perry-hir stable_hash::tests::expr_variant_stable_hash_tags_are_unique.

Ralph Küpper added 3 commits May 31, 2026 10:21
# Conflicts:
#	crates/perry-codegen/src/lower_call/native_table/async_decimal.rs
#	crates/perry-runtime/src/async_hooks.rs
#	crates/perry-stdlib/src/async_local_storage.rs
#	docs/api/perry.d.ts
#	docs/src/api/reference.md
@proggeramlug proggeramlug merged commit a5f83ba into PerryTS:main May 31, 2026
11 checks passed
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.

2 participants