Skip to content

[Bug]: window.self is polluted, causing webpackChunkXxx to not be found when loading chunks #11713

@lzsheng

Description

@lzsheng

System Info

System:
OS: macOS 15.6.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 632.29 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.12.1 - ~/.nvm/versions/node/v20.12.1/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v20.12.1/bin/yarn
npm: 10.5.1 - ~/.nvm/versions/node/v20.12.1/bin/npm
pnpm: 8.15.9 - ~/.nvm/versions/node/v20.12.1/bin/pnpm
Browsers:
Chrome: 140.0.7339.134
Safari: 18.6

Details

项目名称:yqb
报错:Uncaught TypeError: Cannot
read properties of null (reading 'webpackChunkyqb')

经过分析后,是因为在 react 的业务代码修改了 window.self 属性
componentWillUnmount() { window.self = null; }

触发场景,在 A 页面跳转到 B 页面,需要加载 B 页面的 chunk,但是由于在 A 页面执行了 window.self = null 导致加载 chunk 的函数报错了。

Image

Reproduce link

No response

Reproduce Steps

"@rsbuild/core": "^1.5.3",
"@rsbuild/plugin-assets-retry": "^1.4.2",
"@rsbuild/plugin-check-syntax": "^1.3.1",
"@rsbuild/plugin-eslint": "^1.1.2",
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-sass": "^1.4.0",
"@rsbuild/plugin-type-check": "^1.2.4",

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions