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

Fix additional re-render when calling fetchMore from useSuspenseQuery when using startTransition. #11638

Merged
merged 14 commits into from
Mar 5, 2024

Conversation

jerelmiller
Copy link
Member

@jerelmiller jerelmiller commented Mar 4, 2024

Fixes #11315

Due to the mechanics of fetchMore, the cache broadcast happens after the concast promise is resolved. This interferes with our check on promise resolution to see if we need to emit the result to avoid some situations where the promise might otherwise stay pending forever (#11086). Unfortunately this meant that we emitted a result, then the cache result was broadcasted resulting in an additional re-render.

This fix adds a setTimeout around the check to try to allow QueryInfo.notify to run first, which is itself run inside a setTimeout.

Copy link

changeset-bot bot commented Mar 4, 2024

🦋 Changeset detected

Latest commit: 7d07c58

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@apollo/client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Mar 4, 2024

size-limit report 📦

Path Size
dist/apollo-client.min.cjs 38.29 KB (+0.01% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" 46.11 KB (+0.01% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" (production) 43.66 KB (+0.03% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" 33.9 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" (production) 31.82 KB (0%)
import { ApolloProvider } from "dist/react/index.js" 1.23 KB (0%)
import { ApolloProvider } from "dist/react/index.js" (production) 1.22 KB (0%)
import { useQuery } from "dist/react/index.js" 5.26 KB (0%)
import { useQuery } from "dist/react/index.js" (production) 4.35 KB (0%)
import { useLazyQuery } from "dist/react/index.js" 5.5 KB (0%)
import { useLazyQuery } from "dist/react/index.js" (production) 4.58 KB (0%)
import { useMutation } from "dist/react/index.js" 3.51 KB (0%)
import { useMutation } from "dist/react/index.js" (production) 2.73 KB (0%)
import { useSubscription } from "dist/react/index.js" 3.19 KB (0%)
import { useSubscription } from "dist/react/index.js" (production) 2.38 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" 5.36 KB (+0.08% 🔺)
import { useSuspenseQuery } from "dist/react/index.js" (production) 4.03 KB (+0.1% 🔺)
import { useBackgroundQuery } from "dist/react/index.js" 4.83 KB (+0.07% 🔺)
import { useBackgroundQuery } from "dist/react/index.js" (production) 3.49 KB (+0.09% 🔺)
import { useLoadableQuery } from "dist/react/index.js" 4.98 KB (+0.1% 🔺)
import { useLoadableQuery } from "dist/react/index.js" (production) 3.63 KB (+0.11% 🔺)
import { useReadQuery } from "dist/react/index.js" 3.12 KB (+0.16% 🔺)
import { useReadQuery } from "dist/react/index.js" (production) 3.06 KB (+0.16% 🔺)
import { useFragment } from "dist/react/index.js" 2.25 KB (0%)
import { useFragment } from "dist/react/index.js" (production) 2.2 KB (0%)

@jerelmiller
Copy link
Member Author

/release:pr

Copy link
Contributor

github-actions bot commented Mar 4, 2024

A new release has been made for this PR. You can install it with npm i @apollo/client@0.0.0-pr-11638-20240304221457.

Copy link

netlify bot commented Mar 4, 2024

Deploy Preview for apollo-client-docs ready!

Name Link
🔨 Latest commit 6902673
🔍 Latest deploy log https://app.netlify.com/sites/apollo-client-docs/deploys/65e6474017bdc8000852cbb0
😎 Deploy Preview https://deploy-preview-11638--apollo-client-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Mar 4, 2024

Deploy Preview for apollo-client-docs ready!

Name Link
🔨 Latest commit 7d07c58
🔍 Latest deploy log https://app.netlify.com/sites/apollo-client-docs/deploys/65e76550fb9e870008f97be9
😎 Deploy Preview https://deploy-preview-11638--apollo-client-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jerelmiller jerelmiller marked this pull request as ready for review March 4, 2024 22:23
@jerelmiller jerelmiller requested a review from a team as a code owner March 4, 2024 22:23
// TODO: Determine why we have this extra render here. This should mimic
// the update in the next render where we see <App /> included in the
// rerendered components.
// Possibly related: https://github.com/apollographql/apollo-client/issues/11315
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Narrator: It was related

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made me laugh. Also, great we're rid of them now!

query letters($limit: Int, $offset: Int) {
letters(limit: $limit) {
query LettersQuery($limit: Int, $offset: Int) {
letters(limit: $limit, offset: $offset) {
Copy link
Member Author

@jerelmiller jerelmiller Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This offset as a variable is important for cache reasons and it was forgotten 😱. Thankfully no tests were harmed in this change, but it was necessary to reproduce the bug in this PR.

@Arno500
Copy link

Arno500 commented Mar 4, 2024

Hmmm, I can kind of confirm the bug is fixed, but in “rare conditions”, I can trigger a race condition. It is not exactly clear when and how, but it seems that when I spam fetchMore, in some cases, the commit is done later and Apollo struggles to merge everything, leading to a loop where it is trying to fetch indefinitely. Here is the console.log of our app where it does that:

Console log from the browser
{displayCategories: Array(25)} true
Categories.tsx:64 {displayCategories: Array(25)} true
Categories.tsx:64 {displayCategories: Array(25)} true
Categories.tsx:64 {displayCategories: Array(25)} true
Categories.tsx:64 {displayCategories: Array(25)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(25)} true
Categories.tsx:64 {displayCategories: Array(35)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(35)} true
Categories.tsx:64 {displayCategories: Array(35)} true
Categories.tsx:64 {displayCategories: Array(45)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(45)} true
Categories.tsx:64 {displayCategories: Array(45)} true
Categories.tsx:64 {displayCategories: Array(55)} true
Categories.tsx:64 {displayCategories: Array(55)} true
Categories.tsx:64 {displayCategories: Array(55)} true
Categories.tsx:64 {displayCategories: Array(55)} true
Categories.tsx:64 {displayCategories: Array(55)} true
Categories.tsx:64 {displayCategories: Array(45)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(45)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:64 {displayCategories: Array(10)} true
Categories.tsx:43 Fetching more
Categories.tsx:64 {displayCategories: Array(10)} true

Am trying to create or find a reproducer. In our case, this is an infinite scroll page, so calls are expected to be spammed when scrolling fast

@jerelmiller
Copy link
Member Author

@Arno500 just to clarify, are you sure these are related? This seems like it might be a different issue than reported in #11315, but perhaps I'm misunderstanding something. Based on the original reproduction which demonstrates that an additional rerender is happening, this PR seems to fix that issue.

If you think this is different enough, would you mind opening a new issue that we can track separately? A reproduction as you mentioned would also go a long way to help us figure that out.

@Arno500
Copy link

Arno500 commented Mar 5, 2024

Hmmmm, to be honest, I don't really know, but it seems the issue seems to be from the same system.

Here is a reproducer, so you can take a look at the behavior and tell me if it needs another issue: https://stackblitz.com/edit/stackblitz-starters-t7c2zv?file=src%2Fcomponents%2FPaginatedQuery.tsx,src%2Fapp%2Flayout.tsx

It did show before your patch (apparently) but it seems vaguely linked in some ways and appeared on the same project I was working with @pvandamme showing the aforementioned issue.
(also Apollo at some point decides that if the new array is empty, it should clear everything, but this is another issue)

@jerelmiller
Copy link
Member Author

Apologies, I might be missing something, but I'm not seeing what you're describing above, so perhaps this is a different bug 🤷‍♂️? What I do see in that reproduction is that the first item is fetched, then the 2nd item via fetchMore, but that 2nd item is never added to the end of the list, even though its updated in the cache properly. This seems to occur both in 3.9.5 and the snapshot release from this branch.

I think this might be a separate issue. It would definitely help to have any instructions/expected behavior in there that way any fix we have for this can be validated against that reproduction.

@Arno500
Copy link

Arno500 commented Mar 5, 2024

Alright, in that case I will create a new issue!
But the original double render does not happen anymore at least, it's a big win :)

@jerelmiller
Copy link
Member Author

At least there's some good news there! Thanks a bunch ahead of time 🙂

Copy link
Member

@phryneas phryneas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!
It would be great if you could make the test a tad more explicit in one point, but apart from that: Approved!

Comment on lines 10081 to 10091
{
const { snapshot, renderedComponents } = await Profiler.takeRender();

expect(renderedComponents).toStrictEqual([App]);
expect(snapshot.result?.data).toEqual({
letters: [
{ __typename: "Letter", letter: "A", position: 1 },
{ __typename: "Letter", letter: "B", position: 2 },
],
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading the test, it's not immediate apparent why this rerender happens. I'd assume to disable the button - but it might be good in that case to do an expect(button).toBeDisabled to make that obvious.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! d9e2257

@jerelmiller jerelmiller force-pushed the issue-11315-fetchmore-suspense branch from 9705eb2 to 7d07c58 Compare March 5, 2024 18:32
@jerelmiller jerelmiller merged commit bf93ada into main Mar 5, 2024
33 checks passed
@jerelmiller jerelmiller deleted the issue-11315-fetchmore-suspense branch March 5, 2024 18:43
@github-actions github-actions bot mentioned this pull request Mar 5, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pagination using useSuspenseQuery and React transition is broken
3 participants