-
-
Notifications
You must be signed in to change notification settings - Fork 445
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
RangeError: Maximum call stack size exceeded when using persistedExchange in front of ssrExchange #3441
Comments
That feels correct, the fetchExchange is an async exchange while the |
according to docs, |
The reproduction here doesn't reproduce the issue. However, to explain what's going on. For this to become a problem a couple of things need to be the case. Mainly, the exchange(s) after the
Unrelatedly, some notes on the reproduction, which seems to behave fine in its current state:
Overall, while it shouldn't matter whether you place I suspect what you might have seen is an Automatic Persisted Query miss, hence the request repeating? As long as the I hope that clarifies this, but for now I'll mark this issue as “needs more info” ✌️ Edit: I've just seen that you meant the server-side log contains the mentioned error. My bad! They were hidden from me, so I didn't check or notice them, since the client served just fine. I just realised what's going on here,
The The client still renders likely since the rest of the setup isn't actually handling SSR for the client-side, so basically, it's as if you're rendering HTML in Nuxt SSR mode and then discarding the result and building a completely independent result on the client-side. Long story short, the stacktraced error in the Node process (i.e. server-side) can be completely explained by the above, the other issues you're describing are basically expected behaviour given the setup (re. the prior list I provided) |
isn't the idea of ssr exchange - when client hydrates - to NOT execute queries again, because they already have data sent from server? If I remove persisted exchange and leave ssrExchange - client does NOT executes queries. |
See edit; I missed what's going on on the server-side, and that explains the error there, while the rest can be explained by missing setup code, as long as the reproduction is basically what's being run in your case too.
Not necessarily, no. The This is a subtly different goal. After hydration, we don't expect it to act like a cache and that's why it only returns a result once. It basically replaces the The problem with The Edit 2: You're likely aware of this, but just so I address this too, since I forgot. If you add random data to the query, its key changes on every render, i.e. it'll also be different between client-side and server-side and a match can never occur between the two |
Yeah, that was only to reproduce nodejs error. I've tested now and indeed it re-executes query on client-side if there is only ssrExchange, however it does not when you have ssrExchange and then persistedExchange. If I remove persistedExchange - it always re-execute query, even if there is normalized cache. I always though that ssrExchange will prevent client re-execution. In that case - what's the best way to prevent client-side to execute queries that SSR already executed ? |
I'm adding a dev-time warning to this, since it's a very specific case that's clearly just confusing and hard to grasp given the error.
There's a short explanation here: https://formidable.com/open-source/urql/docs/advanced/persistence-and-uploads/#automatic-persisted-queries tl;dr: Run this just as an SPA without SSR to see more clearly what's going on. You may have to check closely what the request looks like. Basically, this is because you're using automatic persisted queries. A second request will be sent when the hash that's sent is unknown to the server. The longer explanation is in the docs ✌️ |
Describe the bug
We have following setup of exchanges
Which leads to
if non-persisted query is executed.
if I exchange ssr in front of persisted Query like that
it works - but it also re-executes queries after hydration on client-side.
Reproduction
https://github.com/Warxcell/urql-ssr-persisted-exchange-demo
Urql version
"@urql/core@>=4.1.0", "@urql/core@^4.0.0":
version "4.2.0"
"@urql/vue@1.1.2":
version "1.1.2"
"@urql/exchange-persisted@^4.1.0":
version "4.1.0"
Validations
The text was updated successfully, but these errors were encountered: