-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
'ObservableQuery with this id doesn't exist: id' on unmounted component #4114
Comments
+1 |
Getting this in our production environment but not our staging or local, no idea how to fix. Update: Issue was caused by an error in a related component, the error boundary caused the Query component to become unmounted. |
I was seeing this, and it ended up being that I was resetting limit variables on a paginated query that uses fetchMore. I was doing it on a child component componentDidUnmount however (so it would be reset when you go back to the screen with the list). This was causing the query to refetch and immediately disappear. Not sure if that's helpful for your issue or not, but figured I'd share! |
I am also getting |
As @sghall i'm getting this also using SSR with |
@rlancer can you elaborate on your solution a little? Trying to diagnose a Sentry error. |
@redreceipt we have a infinite scroll for our main feed with a side bar that also has an infinite scroll, we were only using Apollo to power our main feed, the sidebar ended up crashing and the only error we saw was |
I am also seeing this message. I guess it's because the query response comes back from my server, but the Query HOC has already unmounted, consequently, Apollo Client doesn't know which query to update. |
That just means your query is causing the HOC to be removed from the
Virtual DOM.
…On Mon, Apr 15, 2019, 8:41 AM flyer1 ***@***.***> wrote:
I am also seeing this message. I guess it's because the query response
comes back from my server, but the Query HOC has already unmounted.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4114 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABRuf9emEz4jrX-uRfgJEp6ttHXkBv-0ks5vhHORgaJpZM4YUqnm>
.
|
This error happens to me in the following situation. (always reproducible)
I found a solution for this case; setting different I'm not sure but also suspecting that this not only happens for Hope this helps. |
We have the same issue. It would be great for |
I am seeing this issue using the |
Hitting this issue when the variables of my |
Still hapens for me in 2.6.0. |
I'm having an issue which I think may be related to this. When a query is loading and the component unmounts before the query completes, then the network request gets cancelled (normal behavior). But when a fetchMore is loading and the component unmounts before it completes, then the network request does not get cancelled (abnormal behavior). |
Having faced the same issue with fetchMore. Still thinking how to fix it.. the underlaying component (data search screen) can be unmounted by user by selecting or cancelling search value while fetchMore is still fetching data, be that automatic fetchMore or infinite scroll, the problem arises from the fact that the backend responses are a bit slow. Workaround would be to disallow/delay unmount until fetchMore completes or maybe somehow catch and handle these specific errors outside from raising problem. |
Found solution. The error is raised by Promise returned by the fetchMore call. So, you have to catch that. Insted of just calling (as in all examples):
Instead do (in ES6 syntax):
Then the async error thrown after component unmount is catched. The updateQuery function is not called as error is thrown before that. You could also handle the error a bit better, if more finer error control is needed than just supressing all errors. |
@jounii That works for me, thank you! I wish there was a way to cancel the fetchMore request though. |
@spilist thanks! adding a unique |
@sghall @Ethaan Did you guys manage to resolve this issue? I'm getting the exact same issue as you (randomly works), with the error jumping between I'm using the following packages:
|
Getting the same error |
👀 |
In my case I had a list of components sharing a connected query and found that this line was causing the problem https://github.com/apollographql/apollo-client/blob/master/packages/apollo-client/src/core/ObservableQuery.ts#L601 if you keep at least one component always subscribed to the query you shouldnt get that error |
@amille14 Do you have a snippet of how you added a |
Second: Also curious to know how you add key to a react hook? |
For those curious: Wrapping hook in HOC, and then passing a const Fetcher = ({children}) => {
const result = myHook();
return children(result);
} And then render like so <Fetcher key={someUniqueKey}>
{ results => <SomeComponent results={results} /> }
</Fetcher> |
@jmurret @digitalmaster I simply passed a key in to the const { data, loading, error } = useQuery(myQuery, { variables: { ... }, key: 'some key' }) You can also use a key prop on apollo's <Query query={myQuery} key='some key' variables={{ ... }}>
...
</Query> Note that for the hooks I was using the react-apollo-hooks package. This was before Apollo released official support for hooks. I have no idea if passing a key to Apollo's hooks will work the same way, though I do know that their hooks are based on that package so it might work. |
@amille14 Thanks a ton for sharing that context. Looks like they do differ. Doesn't look like 'key' is part of Apollo React Hook: TypeScript Error: 'key' does not exist in type 'QueryHookOptions<Data, Record<string, any>>' Although this would be a nice feature. |
Hi, We are seeing the issue when running tests in Jest because (I think) Jest fails when exceptions are thrown in promises but not caught. For us, it happens with the For now, we have applied the following patch (to apollo-client v2.4.6) as a workaround, simply to stop Jest seeing the uncaught exception:
Note, we are on apollo-client v2.4.6 because we are using |
I just add key props with my Query Component This is working! my cord ->
|
Migrating from react-apollo-hooks to the official Apollo package squared this for me (ht @amille14 ) |
apollographql/apollo-client#4114 Steps to reproduce: 1. Go to Library 2. While it is loading, go to another view
This commit wraps the `fetchMore` call in a try catch to avoid the runtime error thrown by apollo when navigating from the history view to the campaign view or any other route for that matter. apollographql/apollo-client#4114
I am also facing this issue, any solution alternative to catching the error, |
A lot of the Apollo Client internals have changed since v3 was launched. We recommend trying a more modern version of |
Actual outcome:
Hello,
when any of my react native componets start fetching data and is unmounted befor finish, app yell
:
Possible Unhandled Promise Rejection (id: 0): Error: ObservableQuery with this id doesn't exist: 11
There is any posibility how to prevent/catch/fix it? Its only bad setting or bug?
thanks
Versions
The text was updated successfully, but these errors were encountered: