-
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
Promise thrown by useSuspenseQuery gets stuck "pending" forever when fetchMore request fails #12103
Comments
Hi @qiuzhangxi77, thank you for the bug report, reproduction and solution pointer - that's an amazing level of effort! We're all just back from conferences and part of our team is still out, so we'll need a few days to catch up, but it's really appreciated and we'll take a look as soon as we can! |
Hi @phryneas, thank you for push it in fix progress so quickly!! I also wanted to mention that I had a similar issue with the |
Hey @qiuzhangxi77 👋 Good catch! I opened #12110 which should fix this. Thanks for the detailed report! Made it easy to fix 🙂 As for apollo-client/src/react/hooks/__tests__/useSuspenseQuery.test.tsx Lines 4510 to 4780 in f36b938
|
Hi @jerelmiller , thank you for the quickly fix!! I made a simple example, and it works fine. Maybe I used it incorrectly in my project, which caused the error not to be thrown normally. |
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. |
@qiuzhangxi77 glad to hear its working there! I've gone ahead and merged #12110 and will get that released shortly. Feel free to open a new issue if you end up figuring out that Apollo Client has a bug with |
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
ErrorBoundary cannot catch the error throw by the useSuspenseQuery, since the promise throw by useSuspenseQuery is always pending when fetchMore request promise was rejected caused by some errors.
This is what I found when viewing the implementation.
fetchMore
will setPromise withthis.promise
inQueryReference.ts
. it is different withreturnedPromise
returned byfetchQuery
.this.promise
is created as pending promise ininitiateFetch
and keep pending during the whole process offecthMore
, exceptreturnedPromise
is fulfilled.returnedPromise
handles error capture with the callbackcatch(() => {})
this.promise
is still in pending even though thereturnedPromise
is rejected.this.promise
is what the suspense waits for in my example.Therefore, after executing "fetchMore", the promise throw by useSuspenseQuery is always pending.
Link to Reproduction
Reproduction in code sandbox here
Reproduction Steps
easy to reproduce, just make sure the fetchMore request has an error, like network error or variables error...
@apollo/client version
3.8.8
just tested a solution provider by @destin-estrela , which appears to work from.
The text was updated successfully, but these errors were encountered: