Skip to content

undici: public request crashes reading length from undefined after llhttp loads #10889

Closed

Description

@proggeramlug

Summary

A clean public-entry undici@8.9.0 request fixture compiles and links all 111 source modules on current main (f88acdaa1b), including undici's llhttp WebAssembly dependency, but fails at runtime before completing the local request:

TypeError: Cannot read properties of undefined (reading 'length')
    at <anonymous>

This is the current verified undici blocker.

Reproduction shape

  1. Install undici@8.9.0.
  2. Add undici to perry.compilePackages.
  3. Import { request } from the public undici entry point.
  4. Start a local node:http server and request it.
  5. Compile and run with Perry.

The clean source graph contains 111 compiled modules. No partial-codegen flag or internal package import is used.

Expected

The request completes and exposes the local server response, as under Node.

Actual

The executable throws while reading .length from an undefined value before the request completes.

Corrected provenance

The initial version of this issue reported undefined reference to js_webassembly_module_new. A coherent current-main build with Cargo available to Perry's auto-provisioning path correctly detects WebAssembly, builds perry-wasm-host, enables perry-runtime/wasm-host, and links successfully. That linker error came from the earlier build environment/artifact set and is not reproducible. After linking coherently, the runtime failure above reproduces.

Split from #10797 so undici can be tracked independently.

Activity

  1. added
    package-auditFound by the 2026 package audit: compiling real npm packages from source instead of native bindings
    on Sep 21, 2026
  2. changed the title [-]undici: llhttp WebAssembly dependency fails to link js_webassembly_module_new[/-] [+]undici: public request crashes reading length from undefined after llhttp loads[/+] on Sep 21, 2026
  3. proggeramlug commented on Sep 21, 2026

    @proggeramlug
    ContributorAuthor

    Root cause localized and fixed: PoolBase's computed instance-field keys were being remapped from their class-definition scope to synthetic constructor capture parameters. Those parameters are unbound when the StaticFieldSet key snapshots run, so [kClients] = [] was installed under the wrong key and Pool later failed at this[kClients].length (pool.js:101).

    With the fix applied, that site is gone. The public fixture advances into the HTTP/1 parser and exposes a separate stream-contract failure at client-h1.js:323: Socket.read() returns undefined instead of the null sentinel undici checks. That next blocker is tracked in #10908.

  4. proggeramlug commented on Sep 21, 2026

    @proggeramlug
    ContributorAuthor

    Fixed in v0.5.1633 (merge train 253, 0fa3915293) by #10909 — fix(hir): preserve computed field key scope. The undici crash was not in llhttp itself: computed instance-field keys in nested and CommonJS-wrapped classes were rewritten to unbound constructor-capture parameters, so undici's symbol-keyed pool state never initialised under the symbols its request path reads. Verified by running a_computed_instance_field_key_is_not_a_constructor_capture (passes), and the full perry-hir suite is 471/0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package-auditFound by the 2026 package audit: compiling real npm packages from source instead of native bindings

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions