You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
When a subscription's initial data is returned by the GraphQL server,
the useSubscription hook should:
Set loading to false.
Provide the data in data.
Do this 100% of the time.
Actual outcome:
Approximately 30% of the time (in my case) the initial data is returned by the GraphQL server but loading remains true and data remains undefined.
How to reproduce the issue:
Based on my investigate I believe this issue will occur in any application which uses useSubscription. However due to its intermittent / race condition nature it will be highly dependent on the complexity of the React application, and network conditions.
I have posted a screen cast here demonstrating the issue here.
Root cause:
As identified in the video, I believe the root cause is a race condition in /packages/hooks/src/data/SubscriptionData.ts which implicitly requires that isMounted will be set to truebeforeupdateResult is called, and this is not always the case.
I was having a world of troubles even with this workaround, so ended up attempting to write my own useSubscription hook. It didn't necessarily work any better.. but in case it's useful for anyone:
Intended outcome:
When a subscription's initial data is returned by the GraphQL server,
the
useSubscription
hook should:loading
tofalse
.data
.Actual outcome:
Approximately 30% of the time (in my case) the initial data is returned by the GraphQL server but
loading
remainstrue
anddata
remainsundefined
.How to reproduce the issue:
Based on my investigate I believe this issue will occur in any application which uses
useSubscription
. However due to its intermittent / race condition nature it will be highly dependent on the complexity of the React application, and network conditions.I have posted a screen cast here demonstrating the issue here.
Root cause:
As identified in the video, I believe the root cause is a race condition in
/packages/hooks/src/data/SubscriptionData.ts
which implicitly requires thatisMounted
will be set totrue
beforeupdateResult
is called, and this is not always the case.I haven't investigated further, but it's possible this is also the root cause for:
#3774 #3488 #3361 #3425 #3090 #2899
Version
The text was updated successfully, but these errors were encountered: