GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Cannot read private member from an object whose class did not declare it after upgrading to webpack 5.110.x · Issue #22022 · webpack/webpack

Cannot read private member from an object whose class did not declare it after upgrading to webpack 5.110.x #22022

New issue
Copy link
New issue
Copy link
Closed
Bug
Closed
Cannot read private member from an object whose class did not declare it after upgrading to webpack 5.110.x#22022
Bug
Copy link
Labels
area: optimizationTree-shaking, splitChunks, concatenation, ids (lib/optimize, lib/ids)area: runtimeEmitted runtime and chunk loading across targets (lib/runtime, lib/web, lib/node, lib/esm)regressionWorked in a previous release; pair with the Affected version field

Description

@kyamaz99
kyamaz99
opened on Sep 9, 2026
Issue body actions

Have you used AI?

No

Which part of webpack is affected?

optimization (tree-shaking, splitChunks, concatenation)

Bug Description

When we upgraded to version 5.110.3, we noticed runtime error when running the bundled app
In dev mode, everything works fine.
but when we run build optimization and then read the optimized file , there's a runtime error from one of our dependency.
We managed to boiled down to undici and this part

lib/web/websocket/websocket.js

the code itself hasn't changed in month and it was working in version 5.109.

Digging into the bug, we also noticed that in the reproduction repository

const {}=require('undici') -> no error

but doing

import {} from "undici"->  error

it's seems to be related to esm/cjs interop

Link to Minimal Reproduction and steps to reproduce

https://github.com/kyamaz99/repro-webpack

run

  • npm run build
  • npm run prod

Expected Behavior

same as running

npm run dev

expected in the console to see
OK - no bug

Actual Behavior

the console outputs


    const readyState = ws.#handler.readyState
                          ^

TypeError: Cannot read private member #handler from an object whose class did not declare it
    at ping (/Users/ken.yamazaki/Desktop/projects/repro-webpack/dist/main.js:39864:27)
    at Object.<anonymous> (/Users/ken.yamazaki/Desktop/projects/repro-webpack/dist/main.js:330:21)
    at /Users/ken.yamazaki/Desktop/projects/repro-webpack/dist/main.js:113:17
    at /Users/ken.yamazaki/Desktop/projects/repro-webpack/dist/main.js:40102:1
    at Object.<anonymous> (/Users/ken.yamazaki/Desktop/projects/repro-webpack/dist/main.js:40114:12)
    at Module._compile (node:internal/modules/cjs/loader:1761:14)
    at Object..js (node:internal/modules/cjs/loader:1893:10)
    at Module.load (node:internal/modules/cjs/loader:1481:32)
    at Module._load (node:internal/modules/cjs/loader:1300:12)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)

Environment

⬡ webpack info
────────────────────────────────────────────────────────────────────────
System and environment information.


⬡ System:
────────────────────────────────────────────────────────────────────────
  OS:      macOS 26.6.2
  CPU:     (12) arm64 Apple M2 Pro
  Memory:  106.03 MB / 16.00 GB

⬡ Binaries:
────────────────────────────────────────────────────────────────────────
  Node:  24.12.0 - /Users/ken.yamazaki/.volta/tools/image/node/24.12.0/bin/node
  Yarn:  4.13.0 - /Users/ken.yamazaki/.volta/tools/image/yarn/4.13.0/bin/yarn
  npm:   10.9.7 - /Users/ken.yamazaki/.volta/tools/image/npm/10.9.7/bin/npm

⬡ Browsers:
────────────────────────────────────────────────────────────────────────
  Chrome:  153.0.8010.37
  Edge:    152.0.4191.66
  Safari:  26.6.2

⬡ Packages:
────────────────────────────────────────────────────────────────────────
  webpack:      ^5.110.3 → 5.110.3
  webpack-cli:  ^7.2.3 → 7.2.3

Is this a regression?

Yes (please specify version below)

Last Working Version

v5.109.2

Additional Context

Our current workaround is to pin version 5.109.2, so we are pretty sure where the regression occurred

Activity

  1. kyamaz99
    added the
    Bug
    issue type on Sep 9, 2026
  2. coderabbitai
    added
    area: optimizationTree-shaking, splitChunks, concatenation, ids (lib/optimize, lib/ids)
    area: runtimeEmitted runtime and chunk loading across targets (lib/runtime, lib/web, lib/node, lib/esm)
    regressionWorked in a previous release; pair with the Affected version field
    on Sep 9, 2026
  3. alexander-akait commented on Sep 10, 2026

    @alexander-akait
    alexander-akait
    on Sep 10, 2026 – with Claude
    Member
    More actions

    Thanks for the reproduction — it made this easy to pin down. This is already fixed on main, it just hasn't been released yet.

    The private field is a red herring; the real cause is ASI. undici's index.js is written without semicolons:

    module.exports.ping = ping
    
    module.exports.WebSocketStream = require('./lib/web/websocket/stream/websocketstream').WebSocketStream
    module.exports.WebSocketError = require('./lib/web/websocket/events').WebSocketError

    Under module concatenation WebSocketStream and WebSocketError are unused, so those two statements are rewritten into bare parenthesized module references. In 5.110.3 the leading ; that keeps such a reference off the previous statement was missing:

    module.exports.hU = ping
    /* unused reexport */ /* unused export */ (websocketstream_namespaceFn(), undefined)
    /* unused reexport */ (websocketerror_namespaceFn().WebSocketError)

    which parses as module.exports.hU = ping(…)(…), so ping runs at evaluation time with a namespace object as ws — hence Cannot read private member #handler. That is also why require('undici') was fine and import ... from 'undici' was not: only the ESM path pulls undici into a concatenated scope.

    Fixed by #21962 (fix(concatenate-modules): guard a module reference against ASI), which landed after the v5.110.3 tag. Both CommonJS call sites hardcoded asiSafe: true; the flag is now derived from the position of the original call.

    Verified against your repo with [email protected]:

    webpack result
    5.110.3 TypeError: Cannot read private member #handler …
    commit before #21962 same failure
    current main OK - no bug

    Also green on main with minimize: true and with experiments.outputModule. Closing as fixed — it will go out with the next patch release.


    Generated by Claude Code

    Reacted by kyamaz99
  4. alexander-akait
    closed this as completedon Sep 10, 2026
  5. paulober
    added a commit that references this issue on Sep 13, 2026

    Hold back webpack 5.110.x in Dependabot

    6fde309
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

    area: optimizationTree-shaking, splitChunks, concatenation, ids (lib/optimize, lib/ids)area: runtimeEmitted runtime and chunk loading across targets (lib/runtime, lib/web, lib/node, lib/esm)regressionWorked in a previous release; pair with the Affected version field

    Type

    Bug

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.