Closed apshenichniy closed 1 month ago
Hey @apshenichniy 👋
You're right! We did some refactoring in useSubscription
for 3.11 to better work with React Compiler, but looks like we forgot to add that 3rd argument for SSR. useSyncExternalStore
was added in 3.11 with this.
I'll dig into this soon and try and figure out what we did before in the SSR case to ensure we mimic that here. Thanks for bringing this to our attention!
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.
Hey @apshenichniy 👋
This was just released in 3.11.2. Please upgrade to that version and you should see the error go away. Thanks for reporting this!
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. For general questions, we recommend using StackOverflow or our discord server.
Issue Description
I have a NextJS application using apollo/client v3.11.0. the following error occurs during server-side rendering:
Error: Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering. at Object.useSyncExternalStore (/var/task/node_modules/.pnpm/next@14.2.5_@babel+core@7.24.5_@playwright+test@1.45.1_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:41308)
The snippet below triggered an error:
The error seems to be related to the implementation of the useSubscription hook. Specifically, it appears that the third parameter (callback for getServerSnapshot) is not being passed to the useSyncExternalStore hook: [Link](https://github.com/apollographql/apollo-client/blob/3d9eb47f292206272478056fa138e0a31d84b0aa/src/react/hooks/useSubscription.ts#L221)
Downgrading to @apollo/client version 3.10.8 resolves the issue.
Link to Reproduction
/
Reproduction Steps
No response
@apollo/client
version3.11.0