-
Notifications
You must be signed in to change notification settings - Fork 109
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
Async state hangs on forever in Safari #165
Comments
This is sad, but I am not sure how to progress it further. I do not have Safari at hands to try and debug. I can assist you debugging. Have you tried to put some logging to the app code (before and after await, in render component)? Maybe you need to instrument hookstate API function with more debugging to see what is actually called and what events are fired. And compare it with Chrome for example. Also is the sample from documentation works on safari? |
I was trying to debug this. When I get this issue I sow The example from the documentation works fine in Safari. But I'm afraid that if you will use fetch it will not going to work properly in Safari.
|
"reload" is page refresh, ala F5? |
Empty subscribers list means the 2 components actually refer to another variable, ie. are not rendered on page reload, but the global variable is reset to initial. I do not know how it is possible. You could try to check if a state object, the result/return of useState, still refers to the same |
Yes the "reload" means page refresh F5. Well, the point is that the subscriber list is empty in time of update is fired but later there are components subscribed to the Here we can see in the first example that the components are being subscribed before update is being called and in the second the components are subscribed after the update is called.
How should I check if the state is the same instance? I'm not sure if I understood. |
In the first one there are 2 update calls. Is the second one when the promise is resolved? |
Why do you think in the first one there are 2 update calls? I think in both cases the update is fired only once and in both cases the update is fired AFTER the promise is resolved. I've added log right before the promise is returning the value and it gets printed before the update in both scenarios. |
It is a real puzzle. "How should I check if the state is the same instance? I'm not sure if I understood."
I run out of ideas. I think the best is to plan some zoom session and debug it together. I am in New Zealand time zone and can assist in the evening after 8pm, for example |
Label |
I can do today in the evening 8pm. Email to me to arrange hangouts meeting: avkonst@gmail.com |
Thanks for debugging with me on the meeting. Here is the summary: Sequence of events when a bug is reproduced:
The verified solution: replace useEffect with useLayoutEffect fixes the problem. It forces react to place the subscription before the control is released to the browser. |
Fixed in 3.0.8 |
I'm hitting some really weird bug with:
I've created a reproducable example here: mitas1@d3649bb
Steps to reproduce
I'm trying to load the state in an async way. I'm calling just a dummy fetch see my example. After I will reload the Safari, it will just show the loading state forever. This is some kind of race conditioning bcs. sometimes it works.
I can hit this almost every time I'm reloading the Safari. It works only if I will clear the cache.
My theory is that, maybe due to some cool Safari caching or whatever, if the promise is resolved too soon it will not rerender the state because there is nothing subscribed (cannot be updated) yet.
The text was updated successfully, but these errors were encountered: