Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing data to both client & server component result in always async server tree #74793

Open
kspeyanski opened this issue Jan 11, 2025 · 1 comment
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application. Turbopack Related to Turbopack with Next.js. Webpack Related to Webpack with Next.js.

Comments

@kspeyanski
Copy link

kspeyanski commented Jan 11, 2025

Link to the code that reproduces this issue

https://stackblitz.com/edit/stackblitz-starters-ex8vzvqf?file=app%2Fpage.tsx

To Reproduce

  1. Start the application in development
  2. Observe the code inside page.tsx, components/client.tsx and components/server.tsx.
  3. Note what the children's type of the InternalClientComponent component

Current vs. Expected behavior

  • The children of the InternalClientComponent should be of type: Symbol(React.element) (or Symbol(React.transitional.element) in react-19)
  • However, they are of type Symbol(React.lazy) indicating that they are suspending or awaiting smth, but they are not, they are a simple <button> element.

IMPORTANT NOTES:

  • Not passing the data property to either the ClientComponent or ServerComponent resolves the issue, pointing me that this is mostly related to the data reference, not the components themselves.
  • It is working with next@14
  • If the data is of primitive type, it's also working
  • Not happening during build

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: Ubuntu 20.04.0 LTS Sat Jan 11 2025 21:19:29 GMT+0200 (Eastern European Standard Time)
  Available memory (MB): NaN
  Available CPU cores: 8
Binaries:
  Node: 18.20.3
  npm: 10.2.3
  Yarn: 1.22.19
  pnpm: 8.15.6
Relevant Packages:
  next: 15.2.0-canary.4 // Latest available version is detected (15.2.0-canary.4).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

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

create-next-app, Turbopack, Webpack

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

next dev (local)

Additional context

I tested a different combinations of next 14/15 & react 18/19 as well as dev & build commands and with --turbo flag and webpack respectively - the issue is consistently reproducable since [email protected]

I suspect that passing once a reference to a variable get's passed to a client component it gets turned to a promise so it can travel through the network, however there are also server component that are incorrectly reading the promise (instead of the original variable) which turns them into an async tree -> thus subsequent client components are receiving async server components regardless if they are suspending or not.

@kspeyanski kspeyanski added the bug Issue was opened via the bug report template. label Jan 11, 2025
@github-actions github-actions bot added create-next-app Related to our CLI tool for quickly starting a new Next.js application. Turbopack Related to Turbopack with Next.js. Webpack Related to Webpack with Next.js. labels Jan 11, 2025
@kspeyanski
Copy link
Author

kspeyanski commented Jan 18, 2025

Follow up on this as a I've spared a bit time to debugg it further, i've found a workaround, which is to use structuredClone when passing the same object to one of the environments:

<ClientComponent data={structuredClone(data)}}>
  <ServerComponent data={data} />
</ClientComponent>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application. Turbopack Related to Turbopack with Next.js. Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

1 participant