-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
Unable to use imported objects from client components in server components #71369
Comments
This process includes the following steps: Server Rendering: The Server Component is rendered on the server and produces HTML content. And how can you send an html file to the server??? |
@neefrehman I am not seeing |
@samcx interesting! I can repro that locally and do indeed see the string. On stackblitz it's a different story: Though, I now guess the repro is a bit too minimal, as the string is visible in the server log, but at runtime it seems to still be a proxied object as opposed to the "real" exported one. I think this is shown by the stackblitz logs above, or the When we try to do anything other than log the imported object, we are unable to do so. My use case is similar to the OP of #66212's, using graphql fragments—that are colocated with their component—in another document that may be constructed on the server. The error we see is: It strikes me that this may be related to #51593, and this proxying is also what throws the below error if you tried to do
Is this behaviour documented anywhere? From my understanding Next supports ESM, which would mean these imported objects not being proxied. At least, that's what I initially understood the fix from #66990 to point towards. |
Link to the code that reproduces this issue
https://stackblitz.com/edit/stackblitz-starters-xotxrf?file=app%2Fpage.tsx
To Reproduce
ClientComponent.tsx
null
console.log
on line 4 ofpage.tsx
is commented and then uncommented, you do see the test string in the logs on the first renderCurrent vs. Expected behavior
Currently, It looks like imports from client components into server component are proxied. I would expect to be able to import and use an object or other primitive from a client component, in any other component.
This bug was previously reported in #66212, and supposedly fixed in #66990, but from testing it seems to still be a problem, both with and without turbopack.
From the issue that previously reported this:
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 24.0.0: Mon Aug 12 20:52:12 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6020 Available memory (MB): 32768 Available CPU cores: 10 Binaries: Node: 20.18.0 npm: 10.8.2 Yarn: 1.22.22 pnpm: 9.12.1 Relevant Packages: next: 15.0.0-rc.1 eslint-config-next: 15.0.0-rc.1 react: 19.0.0-rc-83825814-20241015 react-dom: 19.0.0-rc-83825814-20241015 typescript: 5.6.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Runtime, Turbopack
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), Vercel (Deployed)
Additional context
I understand the fix has been reverted from 14 due to it being a breaking change, but I'm expecting it to be there in canary.
The text was updated successfully, but these errors were encountered: