-
Notifications
You must be signed in to change notification settings - Fork 11
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
Devtools refresh on client recreation #325
Comments
Hey @Natas0007 thanks for the awesome feedback ❤️ Just to get this right, this is the expected functionality?
And this is the current functionality?
If so, that makes a tonne of sense and this sounds like we should be doing something to handle new client instances. It looks like the issue is the connection of your initial devtools instance is still alive, meaning devtools doesn't respond in a similar way to a page refresh. My gut instinct here is that we start by terminating any existing chrome runtime connection for a tab whenever a new devtools instance is connected. Devtools isn't designed to support multiple clients anyhow so I can't see this being a problem. |
Thanks @andyrichardson, you're close. I never have 2 active client instances. The initial instance is replaced by a new client instance, as per @kitten's recommendation for completely clearing the client cache. Here are the expectations: Expected functionality
Current functionality
Hopefully this helps. I'll be glad to provide additional detail if needed. Thanks again for your time! |
Thanks, that's super useful!
While you won't have two instances being exposed via context, your initial client instance isn't explicitly torn down so any async actions could still be executing and triggering messages to devtools. We wouldn't(?) want a mix of the two being shown in devtools 🤔 My gut instinct would be to create a new connection upon a new instance of urql devtools and tear down the old one (see here). This would cause devtools to react similarly to a page refresh. If we go with that option we'll need to:
Open to other suggestions! |
Understood. I'll defer to @kitten for thoughts about the recommended solution. Thanks again @andyrichardson! |
Exchanges currently don't have any concept of being torn down as most of them are side-effect-less streams with ad-hoc state that is GC'able as these exchanges stop being used. When the client is swapped out we make the assumption that the framework bindings unsubscribe from all queries which tears down any explicit effect however. (All bindings also do this) There are two exchanges that are the exception in registering. Those are:
The latter becomes a noop after the client stops owning any active operations, so this will become inactive when the client is swapped out — however, for offline we wouldn't recommend this approach just yet and are looking for a patch to improve this. For So from our end, there's nothing stopping this and the plan remains that a client doesn't have to actively be destroyed or torn down, as no work should be ongoing once all operations become inactive (which happens when a client is swapped out in the framework bindings). |
First of all, love the Urql Devtools! I've discovered a minor issue. The devtools do not refresh when the client is completely recreated. My use case for doing this is on user logout for security purposes. I know the client is being recreated successfully as I can log back in (immediately after successful logout) and see my previously ran queries being sent to the server.
I'm using the method originally defined in this issue over in the urql repo: https://github.com/FormidableLabs/urql/issues/297
More specifically, here is my exact custom provider with slight modifications:
As a workaround, I initially tried right click -> "Reload frame" in the devtools to refresh it, but that seems to always completely reset devtools and all results on all tabs until additional queries/mutations are ran. Thank you for your time!
The text was updated successfully, but these errors were encountered: