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

Potential issue when this.store[fetchMoreForQueryId] is undefined #3345

Closed
conrad-vanl opened this issue Apr 19, 2018 · 6 comments · Fixed by #3367
Closed

Potential issue when this.store[fetchMoreForQueryId] is undefined #3345

conrad-vanl opened this issue Apr 19, 2018 · 6 comments · Fixed by #3367

Comments

@conrad-vanl
Copy link
Contributor

conrad-vanl commented Apr 19, 2018

I'm seeing this error logged in a production app every so often:

undefined is not an object (evaluating 'this.store[o].networkStatus=t.NetworkStatus.ready')

I believe I've traced it to here:

if (typeof fetchMoreForQueryId === 'string') {
this.store[fetchMoreForQueryId].networkStatus = NetworkStatus.ready;
}

I see above this function checks for the existence of this.store[queryId], would it make sense to do a similar check for this.store[fetchMoreForQueryId] inside of this conditional? Happy to open a PR, if so.

Trying to think through what could be happening....a fetchMore is triggered, and then resolves after the component is unmounted perhaps? Not sure of how the lifecycle on the graphql HOC plays here.

@rtymchyk
Copy link

rtymchyk commented Apr 20, 2018

I noticed this as well. Does your app use SSR? The way I can reproduce it 100%:

  • SSR a page, that on mount fires a fetchMore query
  • Dismount that component before fetchMore completes (trigger a slow network in dev tools)

I am unable to reproduce this without that initial SSR. So if I load a page on the client that fires a fetchMore, it completes without error, even if the component has dismounted.

In my mind, a dismount should not cause any queries in flight to fail, but it looks to be related to SSR.

@conrad-vanl
Copy link
Contributor Author

No, this is a React native app. So doesn’t seem to be the case for us

@haani104
Copy link
Contributor

haani104 commented Apr 21, 2018

I am facing similar issue.

img_2437

@kdong007
Copy link

same

@hellogerard
Copy link

hellogerard commented Jun 12, 2018

👋 Surfing in here from Google. To add more background to this for anyone else, we encountered this error as well, but only on some of our FlatLists. Then I figured out they differed in how we were working around this bug in FlatList which fired our onEndReached function multiples times on component unmount. By avoiding these spurious calls in "user-land", it fixed the crash in this issue (also saving wasted network requests!).

So while I don't know exactly what's going on in Apollo when a component is unmounted when multiple queries are in flight, I believe this is the a deeper, root cause.

@i6mi6
Copy link
Contributor

i6mi6 commented Sep 13, 2018

Why is this closed? I'm still encountering the issue and submitted a PR #3914

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants