-
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
useLazyQuery throw error when error data is null or undefined #11149
Comments
Hi @quocluongha 👋🏻 I tried running this example but need to debug my local environment further and can't budget the time at the moment. Would you be able to confirm that downgrading to a prior version of |
Yes, downgrading to 3.7 resolves the issue. |
This seems to be triggered by this subscription handler if apollo-client/src/react/hooks/useQuery.ts Lines 152 to 162 in b0a45eb
Wildly guessing here: I assume that was not possible before we had multipart response support, and now we need to guard against that case. @quocluongha The error in the screenshot has nothing to do with |
@plausible-phry I tested it again with the another endpoint contain |
+1 |
I've tested multiple times and it seems this error is not happening on 3.7.16 but is occurring on 3.7.17. |
same |
@versatile-panda sorry, I missed your comment, as I was on vacation. If you are experiencing an error like this with 3.7.17, but not with 3.7.16, it is definitely a different bug as described here. The files with the bug described here were not touched by 3.7.17. Could you please open a new Issue with a more thorough description? @mrlexz I am sorry, but "same" doesn't give me the necessary information to give you any feedback. You might be seeing this bug, you might be seeing a different bug with a similar error surfacing. |
I encountered the same problem starting with version |
@matinzd as I said above, if this started happening with I can see that in |
So I have tried to make another reproduction - again, without any chance of seeing this error myself. You can see my attempt here: Could one of you please take this as a starting point to recreate their problem? |
Hi @phryneas, I'm sorry for my late response. The repo which you provided was using React, but I encountered the error on React Native. |
@quocluongha thanks for the ping! I have to admit, I missed your reproduction - when you originally filed the issue, I was on vacation (I'm @plausible-phry), and I scrolled by it every time after. With your reproduction, I can see the error, and it seems to be an internal timing problem that for some curious reason only happens in React Native. I am working on a fix (still digging for the original reason of this!), but here is a workaround you can already use: you need to add a link that slightly delays the -import {ApolloClient, ApolloProvider, InMemoryCache} from '@apollo/client';
+import {ApolloClient, ApolloProvider, HttpLink, InMemoryCache, Observable, ApolloLink} from '@apollo/client';
import {loadDevMessages, loadErrorMessages} from '@apollo/client/dev';
import React from 'react';
import {StyleSheet} from 'react-native';
import {TestScreen} from './TestScreen';
+const delayCompletionLink = new ApolloLink((operation, forward) => {
+ const observable = forward(operation);
+ const observer = new Observable(obs => {
+ observable.subscribe({
+ next(r) {
+ obs.next(r);
+ },
+ error(e) {
+ obs.error(e);
+ },
+ complete() {
+ setTimeout(() => {
+ obs.complete();
+ }, 100);
+ },
+ });
+ });
+ return observer;
+});
+
const client = new ApolloClient({
- uri: 'https://hasura.sukimashopping.com/v1/graphql',
cache: new InMemoryCache(),
+ link: delayCompletionLink.concat(
+ new HttpLink({uri: 'https://hasura.sukimashopping.com/v1/graphql'}),
+ ),
}); |
Thank you so much! @phryneas |
In our case we are using |
I think I might have solved this. Could you please try the build from #11249 ? npm i @apollo/[email protected] |
I'll give it a try tomorrow! |
This seemed to fix the error for me. |
Just to keep you in the loop here - I have created a PR to fix this more thoroughly over in #11252. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Issue Description
After I upgraded to version 3.8, I noticed that if I call the function returned by useLazyQuery hook and the
data
field of the error isnull
, my app instantly crash even if I wrapped the function call intry
andcatch
block.Link to Reproduction
https://github.com/quocluongha/rn-apollo-test
Reproduction Steps
npm install
oryarn install
.npm run start
oryarn start
.npm run android
/yarn android
for Android ornpm run ios
/yarn ios
for iOS.The text was updated successfully, but these errors were encountered: