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

Remove itAsync part 2 #12207

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Remove itAsync part 2 #12207

wants to merge 18 commits into from

Conversation

jerelmiller
Copy link
Member

@jerelmiller jerelmiller commented Dec 10, 2024

Continuation of #12182

Copy link

changeset-bot bot commented Dec 10, 2024

⚠️ No Changeset found

Latest commit: 91cff26

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@svc-apollo-docs
Copy link

svc-apollo-docs commented Dec 10, 2024

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 1 changed, 0 removed
* (developer-tools)/react/(latest)/data/fragments.mdx

Build ID: ad4f8568faeafa24b1288118

URL: https://www.apollographql.com/docs/deploy-preview/ad4f8568faeafa24b1288118

Copy link

pkg-pr-new bot commented Dec 10, 2024

npm i https://pkg.pr.new/@apollo/client@12207

commit: 91cff26

@jerelmiller jerelmiller force-pushed the jerel/remove-itasync-part-2 branch 3 times, most recently from 8a7a769 to 3035297 Compare December 10, 2024 23:23
@jerelmiller jerelmiller requested a review from phryneas December 11, 2024 23:46
@jerelmiller jerelmiller marked this pull request as ready for review December 11, 2024 23:46
Base automatically changed from jerel/remove-itasync-part-1 to main December 12, 2024 17:47
@jerelmiller jerelmiller force-pushed the jerel/remove-itasync-part-2 branch from c976713 to 6c82bf7 Compare December 12, 2024 17:48
Copy link
Contributor

github-actions bot commented Dec 12, 2024

size-limit report 📦

Path Size
dist/apollo-client.min.cjs 40.66 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" 50.07 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" (production) 47.18 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" 36.18 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" (production) 33.58 KB (0%)
import { ApolloProvider } from "dist/react/index.js" 1.26 KB (0%)
import { ApolloProvider } from "dist/react/index.js" (production) 1.24 KB (0%)
import { useQuery } from "dist/react/index.js" 5.21 KB (0%)
import { useQuery } from "dist/react/index.js" (production) 4.29 KB (0%)
import { useLazyQuery } from "dist/react/index.js" 5.7 KB (0%)
import { useLazyQuery } from "dist/react/index.js" (production) 4.78 KB (0%)
import { useMutation } from "dist/react/index.js" 3.62 KB (0%)
import { useMutation } from "dist/react/index.js" (production) 2.84 KB (0%)
import { useSubscription } from "dist/react/index.js" 4.42 KB (0%)
import { useSubscription } from "dist/react/index.js" (production) 3.48 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" 5.51 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" (production) 4.17 KB (0%)
import { useBackgroundQuery } from "dist/react/index.js" 5.01 KB (0%)
import { useBackgroundQuery } from "dist/react/index.js" (production) 3.66 KB (0%)
import { useLoadableQuery } from "dist/react/index.js" 5.09 KB (0%)
import { useLoadableQuery } from "dist/react/index.js" (production) 3.74 KB (0%)
import { useReadQuery } from "dist/react/index.js" 3.41 KB (0%)
import { useReadQuery } from "dist/react/index.js" (production) 3.35 KB (0%)
import { useFragment } from "dist/react/index.js" 2.36 KB (0%)
import { useFragment } from "dist/react/index.js" (production) 2.31 KB (0%)

Copy link

netlify bot commented Dec 12, 2024

Deploy Preview for apollo-client-docs ready!

Name Link
🔨 Latest commit 91cff26
🔍 Latest deploy log https://app.netlify.com/sites/apollo-client-docs/deploys/678094c30e1f4b0008215dac
😎 Deploy Preview https://deploy-preview-12207--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 force-pushed the jerel/remove-itasync-part-2 branch from 6c82bf7 to f2defe9 Compare January 8, 2025 01:08
@jerelmiller jerelmiller force-pushed the jerel/remove-itasync-part-2 branch from f2defe9 to ba16e3d Compare January 8, 2025 01:28
});

return new ObservableStream(
queryManager.watchQuery<any>(assign({ query, variables }, queryOptions))
Copy link
Member

Choose a reason for hiding this comment

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

Just as a note, we should probably get rid of lodash in a follow-up PR

Copy link
Member Author

Choose a reason for hiding this comment

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

agreed

};
await expect(stream).toEmitError(
new ApolloError({
graphQLErrors: [null as any],
Copy link
Member

Choose a reason for hiding this comment

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

Do we have another test somewhere else that test handling of the message for `null?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not to my knowledge, but I was more focused on updating tests to ObservableStream that I didn't pay attention if there was.


stream.unsubscribe();

await expect(stream).not.toEmitAnything();
Copy link
Member

Choose a reason for hiding this comment

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

This tests more our implementation of ObservableStream than the underlying observable - I think we can skip this line

Suggested change
await expect(stream).not.toEmitAnything();

Copy link
Member

Choose a reason for hiding this comment

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

There are a few more occurances on this, but trying to comment on that file almost crashes my browser, so I'll not mention them.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in cfdffaf with a bit better way to check that polling queries are properly stopped after unsubscribing

expect(queryManager.mutationStore).toEqual({});
});

xit("should only refetch once when we store reset", async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Could we change this to test.skip while we're at it so we can find skipped tests more easily in the future?

Suggested change
xit("should only refetch once when we store reset", async () => {
it.skip("should only refetch once when we store reset", async () => {

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 catch! I missed this when I went through this file.

resetStore(queryManager).then(resolve, reject);

await resetStore(queryManager);
// Ensure the promise doesn't reject
Copy link
Member

Choose a reason for hiding this comment

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

Do we end up with a promise that neither rejects nor resolves here? That would be a pretty critical memory leak 😬

Copy link
Member Author

Choose a reason for hiding this comment

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

It kind of looks that way. I'm going to leave this for now, but ultimately I think this test will disappear. Its testing fetchQuery which is a private function 🤦‍♂️. I'd like to test this from an end user perspective. When that happens I'll refactor this to check it different.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok even worse than I thought. This test is starting the fetch, then removing the query from this.queries in QueryManager, then calling resetStore to make sure the in-flight request doesn't reject.

To be honest, I'm not entirely sure the situation this is trying to check against since end users won't at all be doing this in their own apps. I believe we reject promises if you cancel them in-flight, so I don't know this is an actual real-world situation 🤦‍♂️


await expect(stream).toEmitMatchedValue({ data });

const conditional = jest.fn(() => []);
Copy link
Member

Choose a reason for hiding this comment

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

The name of this test is "also works with a conditional function that returns false",, why does this return []? 😢 (not yourfault, just venting!)

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.

This took a while to work through... I'm happy with your changes, but you've uncovered a bunch of tests that really need a rework at some point 😅

@github-actions github-actions bot added the auto-cleanup 🤖 label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants