Skip to content

cjs: find-my-way@9 init throws 'Cannot convert undefined or null to object' — blocks #6559 e2e #6587

Closed

Description

@proggeramlug

Found while landing #6559 (PR #6584): find-my-way@9 compiles natively (compilePackages) but throws TypeError: Cannot convert undefined or null to object at load — before any route is registered or any runtime-generated code runs.

Uncharacterized beyond the failure point: something during module init passes undefined/null into an Object.* operation (likely Object.keys/assign/setPrototypeOf over a value perry resolves differently at CJS init — needs a bisect into find-my-way's init graph: handler-storage maps, http-methods table, or its Object.create(null) trees).

Repro: the #[ignore]d e2e in crates/perry/tests/issue_6559_real_libs_e2e.rs (PERRY_REQUIRE_NPM_E2E=1 … -- --ignored).

Blocks: #6559 real-library acceptance (router leg), kimi-code target #6565 (fastify routing = find-my-way). Interpreter side already proven against find-my-way's captured matcher codegen incl. new NullObject() on a host class (PR #6584 fixtures).

Activity

  1. added
    bugConfirmed defect or regression
    parityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem
    on Jul 18, 2026
  2. proggeramlug commented on Jul 18, 2026

    @proggeramlug
    ContributorAuthor

    Resolved by #6598 (merged to main as 49db1ac).

    Root cause: OrdinaryHasInstance (ECMA-262 7.3.21) with a null/undefined left operand threw TypeError: Cannot convert undefined or null to object instead of returning false. find-my-way@9's FindMyWay(opts) is called without new, so its Router body evaluates this instanceof Router with this === undefined; because the RHS is a function value, it routed through js_instanceof_dynamic's prototype-walk tail (ordinary_has_instance_prototype_walk), which called getPrototypeOf(undefined) and aborted module init before any route was registered.

    Fix: the prototype walk now short-circuits to false for every non-object LHS (null/undefined/boolean/int32/string/bigint/symbol), per step 3 ("If Type(O) is not Object, return false"), and Symbol() instanceof Object is now false. Verified byte-identical to Node across 26 instanceof cases; real_find_my_way_router in crates/perry/tests/issue_6559_real_libs_e2e.rs is un-ignored and green.

    Note: one minor CodeRabbit suggestion — set PERRY_REQUIRE_NPM_E2E=1 for the e2e-scoped CI job so that e2e can't silently skip — was not included in #6598 and remains as optional CI hardening.

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

    bugConfirmed defect or regressionparityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions