vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.61k stars 26.82k forks source link

Cannot read properties of undefined (reading 'H') #71004

Open cjkihl opened 1 day ago

cjkihl commented 1 day ago

Link to the code that reproduces this issue

https://github.com/cjkihl/issue-nextjs

To Reproduce

  1. Run npm run dev
  2. Go to http://localhost:3000/test
  3. Server error
  4. This error only occurs using the edge runtime. Switch to the nodejs runtime and it works

Current vs. Expected behavior

You will get a server error:

TypeError: Cannot read properties of undefined (reading 'H')
@cj/site:dev:     at performWork (webpack-internal:///(rsc)/../../node_modules/.pnpm/next@15.0.0-canary.179_@opentelemetry+api@1.9.0_babel-plugin-react-compiler@0.0.0-experimenta_ek5dtgab3jgmtt4m6yrzmbeut4/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.edge.development.js:6468:49)
@cj/site:dev:     at AsyncLocalStorage.run (node:async_hooks:346:14)
@cj/site:dev:     at eval (webpack-internal:///(rsc)/../../node_modules/.pnpm/next@15.0.0-canary.179_@opentelemetry+api@1.9.0_babel-plugin-react-compiler@0.0.0-experimenta_ek5dtgab3jgmtt4m6yrzmbeut4/node_modules/next/dist/compiled/react-dom/cjs/react-dom-server.edge.development.js:7206:35)
@cj/site:dev:     at node:internal/process/task_queues:140:7
@cj/site:dev:     at AsyncResource.runInAsyncScope (node:async_hooks:206:9)
@cj/site:dev:     at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)

Go to the file src/app/test/route.tsx and change runtime environment to nodejs

Now the code will work as expecred

Provide environment information

Node.js v20.13.1

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.5.0: Wed May  1 20:19:05 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8112
  Available memory (MB): 8192
  Available CPU cores: 8
Binaries:
  Node: 20.13.1
  npm: 10.5.2
  Yarn: 4.2.2
  pnpm: N/A
Relevant Packages:
  next: 15.0.0-rc.0 // Latest available version is detected (15.0.0-rc.0).
  eslint-config-next: 15.0.0-rc.0
  react: 19.0.0-rc-f994737d14-20240522
  react-dom: 19.0.0-rc-f994737d14-20240522
  typescript: 5.6.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

create-next-app, Runtime, Webpack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

Error occurs in Nextjs 15rc

"react": "19.0.0-rc-f994737d14-20240522",
"react-dom": "19.0.0-rc-f994737d14-20240522",
"next": "15.0.0-rc.0"
cjkihl commented 1 day ago

This works as expected if you downgrade to nextjs 14 and react 18:

"react": "18.3.1",
"react-dom": "18.3.1",
"next": "14.2.15"