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

Uncaught TypeError: obsQuery.resubscribeAfterError is not a function #11632

Closed
naveenkrish-17 opened this issue Mar 1, 2024 · 5 comments
Closed

Comments

@naveenkrish-17
Copy link

We are facing a unique issue in our single page application. Our application is SSR. At home page we are firing 4 GraphQL queries. The results are getting cached when checked in Apollo dev tools. When we navigate to next page we fire two queries. We are redirecting to external application from this page as per functional requirement to an application out of our control. When we navigate back to our application using browser back button another load of our application is happening which is fair and we see two GraphQL queries as needed. But when checked in Cache from Apollo dev tools, one of the result from GraphQL is getting deleted. This deleted result is needed in the home page which we can reach by clicking browser back button again. Weirdly when we reach the home page or initial page of the application, the useQuery is getting fired bu resulting in below error and we end up getting loading as true and thats it.

Uncaught TypeError: obsQuery.resubscribeAfterError is not a function
at Object.onError [as error] (useQuery.ts:247:1)
at notifySubscription (module.js:137:1)
at onNotify (module.js:176:1)
at SubscriptionObserver.error (module.js:229:1)
at iteration.ts:13:1
at Array.forEach ()
at iterateObserversSafely (iteration.ts:13:1)
at ObservableQuery.reportError (ObservableQuery.ts:907:1)
at Object.error (ObservableQuery.ts:844:1)
at iteration.ts:13:1

All GraphQL calls are using the same resolver for Apollo Client and input params look the same between successful request occured in forward journey and the failed request during backward journey
Kindly help

@phryneas
Copy link
Member

phryneas commented Mar 1, 2024

Hi there :)

This is quite a lot, so I'm trying to separate a few things here.

  • Generally, Apollo Client is an in-memory cache. We don't persist anything between different page views.
  • If you do an external navigation, and use the back button from there, your application will start up from zero again (maybe with additional navigation state, but all internal state will be reset).
  • So we're probably looking at a "fresh page load" here - you should have a similar situation if you just press F5 instead of navigating away from the page and navigating back to it. Could you verify that?
  • As for your obsQuery.resubscribeAfterError, I've looked at the according code paths, and to me it looks like this error should not be possible (at least in the most recent version of Apollo Client - if you are on a different version of AC, could you please tell us?)
  • As a result of that, I assume that this specific error might be caused by some weird situation incurring your bundler (again, if you're on the latest version of AC).
    In that case, it would be impossible for us to reproduce this on our machines - you really would need to provide us with a reproduction or an opportunity to observe this behaviour "in the wild" to say anything more about that.
  • It also seems weird to me that you get an error because "something is missing in the cache" - you seem to be using useQuery here.
    That would make a network request if something is missing, not just crash because nothing is in the cache. Do you see that outgoing request happening?

@navattri
Copy link

@naveenkrish-17 I had the same issue. Updating apollo-client to latest version fixed it for me.

@phryneas
Copy link
Member

We didn't see a response from the original author in a long time and as per report it seems to work in newer versions, so I'm going to close this issue. If this still happens in new versions, pleas open a new issue.

Copy link
Contributor

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.

Copy link
Contributor

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.
For general questions, we recommend using StackOverflow or our discord server.

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

No branches or pull requests

4 participants