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

POC reproduction of Issue #9204 #9407

Conversation

jamesopti
Copy link
Contributor

Checklist:

Confirmed this test fails with an infinite loop in v3.5.8 and passes in v3.4.17

@apollo-cla
Copy link

@jamesopti: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@@ -219,8 +221,7 @@ export function useQuery<
return () => subscription.unsubscribe();
}, [obsQuery, context.renderPromises, client.disableNetworkFetches]);

let partial: boolean | undefined;
({ partial, ...result } = result);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have to assume there was a reason for doing this that I don't understand, but it is one of the underlying causes of the loss of identity stability in the return value.

The result of the change here is that result continues to include the partial field, but it could be removed and maintain identity stability via delete result.partial

Copy link
Member

Choose a reason for hiding this comment

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

This got fixed in PR #9459, and now works without rebinding any variables:

const { data, partial, ...resultWithoutPartial } = result;

Copy link
Member

@benjamn benjamn left a comment

Choose a reason for hiding this comment

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

@jamesopti Thanks so much for submitting these test cases, and for making actual progress on fixing them. I cherry-picked your test cases and initial fixes into my PR #9459, which we just merged into release-3.6 and published in @apollo/[email protected], so you should be able to test the changes in your app(s) by running npm i @apollo/client@beta. Let us know how it goes!

Comment on lines +32 to +35
const watchQueryOptions = useMemo(
() => createWatchQueryOptions(query, options, defaultWatchQueryOptions),
[query, options, defaultWatchQueryOptions]
)
Copy link
Member

Choose a reason for hiding this comment

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

One fun bug: this useMemo works great as long as options is undefined (just useQuery(query)), but as soon as you call useQuery(query, {...}) with options, that's a fresh object for useMemo, so watchQueryOptions gets regenerated with every useMemo call.

@@ -219,8 +221,7 @@ export function useQuery<
return () => subscription.unsubscribe();
}, [obsQuery, context.renderPromises, client.disableNetworkFetches]);

let partial: boolean | undefined;
({ partial, ...result } = result);
Copy link
Member

Choose a reason for hiding this comment

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

This got fixed in PR #9459, and now works without rebinding any variables:

const { data, partial, ...resultWithoutPartial } = result;

@benjamn
Copy link
Member

benjamn commented Mar 10, 2022

Closing because these commits were incorporated into #9459, which has been merged into release-3.6.

@benjamn benjamn closed this Mar 10, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
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.

3 participants