Skip to content

ethers: link fails with undefined reference to __perry_wrap_perry_fn_..._ws_ts__WebSocket #11044

Closed

Description

@proggeramlug

ethers@6.17.0's original compile blocker (#10757, HIR lowering hang on @noble/curves' weierstrass.js) is fixed — the package now compiles cleanly from real source (153 modules: ethers, @adraffy/ens-normalize, @noble/curves, @noble/hashes, aes-js). Linking fails with an undefined reference to a WebSocket wrapper symbol that codegen never emitted:

/usr/bin/ld: .../perry_closure_node_modules_ethers_src_ts_providers_provider_websocket_ts__1: in function ...:
undefined reference to `__perry_wrap_perry_fn_node_modules_ethers_src_ts_providers_ws_ts__WebSocket'
collect2: error: ld returned 1 exit status
Error: Linking failed

Reproduction

{
  "dependencies": { "ethers": "6.17.0" },
  "perry": {
    "compilePackages": ["ethers"],
    "allow": { "compilePackages": ["ethers"] }
  }
}

fixture.ts:

const { ethers } = require("ethers");

const pk = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
const wallet = new ethers.Wallet(pk);
console.log("address:", wallet.address);
npm install
perry compile fixture.ts -o fixture

Expected

Links and runs; node fixture.ts (via --experimental-strip-types) prints:

address: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

Actual (Perry, current main)

Link failure — collect2: error: ld returned 1 exit status, Error: Linking failed, naming __perry_wrap_perry_fn_node_modules_ethers_src_ts_providers_ws_ts__WebSocket as undefined.

Notes

  • ethers/src.ts/providers/provider-websocket.ts imports a local ./ws.js/ws.ts shim that ethers ships internally (its own thin WebSocket wrapper around whatever runtime WebSocket is available), and provider-websocket.ts builds a closure that references it. The mangled symbol name (__perry_wrap_perry_fn_..._ws_ts__WebSocket) suggests codegen registered a call site expecting a native-function wrapper for this locally-defined WebSocket symbol but never emitted (or the linker never pulled in) the wrapper's definition — this fixture never actually opens a WebSocket connection (Wallet construction alone triggers it), so the failure is purely at compile/link time, not runtime.
  • The reference-taking closure is specifically provider-websocket.ts's module-level closure Support custom menu bar items #1, per the mangled name; that's the most direct lead for whoever picks this up. Not yet bisected further — this fixture doesn't need a real reproduction to trigger the link failure, so a minimal non-ethers repro is likely reachable by isolating whatever HIR/codegen pattern provider-websocket.ts uses to reference its local WebSocket import.

Activity

  1. added
    package-auditFound by the 2026 package audit: compiling real npm packages from source instead of native bindings
    on Sep 22, 2026
  2. added 3 commits that reference this issue on Sep 23, 2026
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