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

rexecuteQuery escapes Suspense boundary #1180

Closed
StevenLangbroek opened this issue Nov 27, 2020 · 5 comments · Fixed by #1181
Closed

rexecuteQuery escapes Suspense boundary #1180

StevenLangbroek opened this issue Nov 27, 2020 · 5 comments · Fixed by #1181
Labels
bug 🐛 Oh no! A bug or unintented behaviour.

Comments

@StevenLangbroek
Copy link
Contributor

StevenLangbroek commented Nov 27, 2020

Hey folks, found a little issue with suspense:

urql version & exchanges:

version: [email protected]
exchanges: graphcache + built-ins

Steps to reproduce

Expected behavior

Refetching a query should trigger the suspense boundary

Actual behavior

Refetching a query completely bypasses Suspense and leads to an uncaught "exception" (the promise that should be suspended on) 🤷

@StevenLangbroek StevenLangbroek added the bug 🐛 Oh no! A bug or unintented behaviour. label Nov 27, 2020
@kitten
Copy link
Member

kitten commented Nov 27, 2020

My first thought here is that I don't think it's possible for us to prevent this from happening as this behaviour is a side-effect that can only be driven into triggering the Suspense boundary if it re-renders.

However to re-render the function would have to alter some state to trigger React to update. We'd only want that to happen once though, but we can't control this to be a guarantee to happen only once, as React doesn't make this guarantee itself anymore.

So long story short, I believe the two patterns — Suspense and executeQuery — are incompatible with one another.

What we could do is force executeQuery to never trigger any suspense behaviour internally though

@StevenLangbroek
Copy link
Contributor Author

What we could do is force executeQuery to never trigger any suspense behaviour internally though

That sounds to me like how it should behave. I would expect we would need to handle result.fetching then, where it would specifically deal with just refetching state. What do you think?

@StevenLangbroek
Copy link
Contributor Author

Suspense without react@experimental's useTransition could not possibly support this I think, no (because the render tree is blown out, I would imagine you lose urql-internal state)

@kitten
Copy link
Member

kitten commented Nov 27, 2020

@StevenLangbroek I do think you'd have to handle it; However, it would mean that the previous content would stay mounted, which actually is rather nice as far as loading behaviour goes, since that means if it's not handled, the content still doesn't break.

@StevenLangbroek
Copy link
Contributor Author

Yep agree!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Oh no! A bug or unintented behaviour.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants