-
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
Cannot read properties of undefined (reading 'data') #12053
Comments
All of that code has been rewritten from the ground in newer versions of Apollo Client - could you please update to a current version? :) |
Oh! I'm updating now, thanks! I'll let you know the results after |
Guys, we are on the v3.11.4 and this code does not differ from the latest one (v3.11.8). Attaching the stacktrace (lines may be incorrect): TypeError: Cannot read property 'data' of undefined I think we are getting the same error, I may be wrong. |
@Cattari that looks very similar but its difficult to tell. If you're able to reproduce this, would you be able to put together a runnable reproduction for us? That would be super helpful to understanding whats happening here. That |
@Cattari line 353 of var globalDefaults = client.defaultOptions.watchQuery; no access to To verify, try |
@phryneas as I said, lines maybe wrong. I got this stacktrace from a symbolication from the release build in React Native. I checked the lining before, it's wrong. But the stacktrace with function naming and paths are correct. So, ignore the lines here, please. The question is: May the |
There are currently two code paths in const currentResultOverride = React.useMemo(
() =>
resultOverride &&
toQueryResult(resultOverride, previousData, observable, client),
[client, observable, resultOverride, previousData]
); As you can see, this does a check on The other call is resultData.current = toQueryResult(
unsafeHandlePartialRefetch(nextResult, observable, partialRefetch),
resultData.previousData,
observable,
client
); And here, There are two more call sites from |
Checking these real quick: toQueryResult(
observable.getCurrentResult(),
resultData.previousData,
observable,
client
)
This would only leave concast.subscribe({
next: (value) => {
result = value;
},
complete: () => {
resolve(
toQueryResult(result, resultData.previousData, observable, client)
);
},
}) This could in theory have Could that be the case? |
I believe result can be undefined when the request hook is interrupted, for example if while fetching we make a different request that will interrupt the previous one. |
Related: #11846. I knew this looked familiar but couldn't find the issue until just moments ago 😅. |
That is an interesting thought, but I don't think that is the cause:
Yeah, I also had that in mind, but we fixed that in 3.11.4, so it can't be that :/ I'm a bit out of ideas. Could you share a replay of this happening with one of us privately? |
We are updating Apollo client first like you said, we are running tests now. Since it happens very often in one of our Cypress tests we'll soon know if it's fixed. I'll be back with the results. Thank you again |
Guys, we have an update. Sorry, for confusing. It was our fault. We were using fromPromise utility and our promise was returning undefined. So, guys, who faces the same issue, make sure your promise you put inside fromPromise @apollo/client func does not return undefined. @phryneas @julianCast FYI |
Getting same issue attaching a screenshot of IOS Simulator that may help to analyse it. Error is like this @julianCast @Cattari @phryneas @jerelmiller have a look |
@puneetkansal04 what version of Apollo Client are you using? |
apollo version 3.11.8 @jerelmiller |
@puneetkansal04 any chance you could provide a reproduction of the issue? This one has been difficult to track down without a way to reproduce it since we haven't been able to narrow down why |
@jerelmiller for reproducing i think if you will hit multiple queries and then you will expire the token then in that queries i think you will get this error. Because i don't know deep about this. |
@puneetkansal04 I'm not sure what you mean by "expire the token". Can you explain further? Better yet, can you put together a reproduction? You can use our error template as a starting point to help demonstrate the issue. |
We're closing this issue now but feel free to ping the maintainers or open a new issue if you still need support. Thank you! |
Hi @julianCast |
Thank you for the hint, I'll try that! |
Issue Description
Hi! We are getting these error randomly:
Link to Reproduction
None
Reproduction Steps
No response
@apollo/client
version3.9.11
The text was updated successfully, but these errors were encountered: