-
Notifications
You must be signed in to change notification settings - Fork 36
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
Intermittent missing client during client redirects #305
Comments
One thing: that Could you please replace that with 'use client'
export function ApolloWrapper() {
return (
<ApolloProvider makeClient={() =>
createApolloClientBase({
/*...*/
})}>
{children}
</ApolloProvider>
);
} just so we have a better place to start from? That said, to me that error looks like it is coming from a component that is somewhere outside of your |
I will work on removal of the useState... it's not super straightforward because we do use the client elsewhere in hooks in the component but should be possible. My understanding of nextjs layouts is that everything is inside the root |
Could you split the layout into two components? One wrapper that just contains the Provider, and then your code in a child class that calls That way we could also rule out any components outside the tree. Generally, I have to say I'm sorry, but I'm not sure how I can help you without a reproduction. 😞 I have never seen this happen and don't know where I could even start looking for it, I'm really sorry! |
@phryneas thanks for your thoughts / ideas. I haven't had time to apply your suggestions yet today, but will give it a go soon. I understand the lack of reproduction makes this difficult to offer guidance on! I will report back if I discover anything but feel free to close out this issue if you'd like and thanks again! |
Hi @phryneas , Fortunately, It looks like this issue is resolved for us and I wanted report back what I've learned. Unfortunately it's nothing super concrete but hopefully will be useful context for someone in the future. I was not able to 100% identify the root cause. What I ended up doing was:
We haven't seen the My only guess as to what happened (and maybe this makes no sense) is that there is some race condition with network loading where before the fix, sometimes |
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. |
Forgot to add: Thanks again for your input & time on this issue. While you didn't have a concrete suggestion, that was still helpful guidance in understanding I wasn't totally crazy in terms of our implementation :) |
Great to hear you solved the issue - thanks for keeping me updated :) |
I'm seeing an error in our e2e tests on CI that I cannot reproduce locally. This issue is flaky, but is happening fairly often. I have a component that will throw the following invariant error:
https://www.apollographql.com/docs/react/errors#%7B%22version%22%3A%223.10.4%22%2C%22message%22%3A49%2C%22args%22%3A%5B%5D%7D
This appears to occur only in tests that call
redirect()
in client components conditionally based off the render of a query. The error is thrown in a separate component in the layout that has it's own query. I'm struggling to create a MRE since i cannot even re-create the issue in the same code locally, but pseudo-code is something like the following.I'd be grateful for any guidance on how to capture more information / anything I can try to get to the bottom of the issue! Thank you!
Versions:
@apollo/client@npm:3.10.4
@apollo/experimental-nextjs-app-support@npm:0.10.1
The text was updated successfully, but these errors were encountered: