Skip to content

fix(fetch): support Headers init and iteration#3464

Merged
proggeramlug merged 6 commits into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-headers-collection-semantics
May 31, 2026
Merged

fix(fetch): support Headers init and iteration#3464
proggeramlug merged 6 commits into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-headers-collection-semantics

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

@andrewtdiz andrewtdiz commented May 30, 2026

Fixes #3440
Fixes #2645

Summary

  • Support new Headers(init) for records, arrays/sequences, Maps/custom sync iterables, and existing Headers clones.
  • Coerce header init names and values through JS string conversion, and throw TypeError for null init or malformed constructor pairs.
  • Make first-class Headers method reads callable and stable enough for collection usage, with Symbol.iterator/@@iterator aliasing entries so spread, Array.from, and for...of work.

Why batched

Both issues target the same Headers collection semantics surface. Constructor materialization, iterator lookup, and runtime method dispatch share the same code paths, so fixing them together avoids splitting one behavior change across multiple PRs.

Tests

  • cargo fmt --all
  • cargo check -p perry-runtime -p perry-stdlib -p perry-codegen -p perry
  • PERRY_NO_AUTO_OPTIMIZE=1 ./run_parity_tests.sh --suite node-suite --module fetch --filter headers
  • PERRY_NO_AUTO_OPTIMIZE=1 CARGO_TARGET_DIR=/tmp/perry-headers-target cargo build --release -p perry -p perry-runtime -p perry-stdlib
  • Manual isolated parity compare with /tmp/perry-headers-target/release/perry:
    • test-parity/node-suite/fetch/headers/append-combines.ts
    • test-parity/node-suite/fetch/headers/constructor-init.ts
    • test-parity/node-suite/fetch/headers/get-set-cookie.ts
    • test-parity/node-suite/fetch/headers/iterable-symbol.ts
  • cargo fmt --all -- --check
  • git diff --check
  • ./scripts/check_file_size.sh

Non-goals

  • This does not broaden unrelated fetch/body behavior.
  • This does not address other Headers edge cases beyond constructor init, cloning, iterator lookup, and first-class method reads covered by the linked issues and added parity cases.

@andrewtdiz
Copy link
Copy Markdown
Contributor Author

Updated this branch for the current mainline.

  • Merged origin/main through 04d9936e3.
  • Rebuilt the release CLI and regenerated the API manifest outputs; docs were already current after the merge.
  • Local checks passed: cargo fmt --all -- --check, git diff --check, ./scripts/check_file_size.sh, CARGO_TARGET_DIR=/root/perry/target cargo test -p perry-api-manifest sys_alias_mirrors_util_manifest, RUST_TEST_THREADS=1 CARGO_TARGET_DIR=/root/perry/target cargo test -p perry-stdlib headers, and CARGO_TARGET_DIR=/root/perry/target cargo test -p perry-hir stable_hash::tests::expr_variant_stable_hash_tags_are_unique.

@andrewtdiz andrewtdiz changed the title fix(fetch): support Headers collection init and iteration fix(fetch): support Headers init and iteration May 30, 2026
Ralph Küpper added 4 commits May 31, 2026 08:48
@proggeramlug proggeramlug merged commit da79959 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.

node:globals: make Headers iterable without crashing Fetch Headers: support iterable and cloned constructor init

2 participants