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(query-core): add error management around this.setData(data) #7642

Closed

Conversation

robin4a4
Copy link
Contributor

This aim to fix #6954. I am not sure that the test perfectly reproduces the initial issue as I am really new to this code base but it was failing before the try catch and seems to pass after the fix.

Copy link

vercel bot commented Jun 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
query ⬜️ Ignored (Inspect) Visit Preview Jun 28, 2024 7:40pm

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 3277657:

Sandbox Source
@tanstack/query-example-angular-basic Configuration
@tanstack/query-example-react-basic-typescript Configuration
@tanstack/query-example-solid-basic-typescript Configuration
@tanstack/query-example-svelte-basic Configuration
@tanstack/query-example-vue-basic Configuration

Copy link

nx-cloud bot commented Jul 21, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 8b4edd3. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


🟥 Failed Commands
nx affected --targets=test:sherif,test:knip,test:eslint,test:lib,test:types,test:build,build --parallel=3
✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

Copy link

pkg-pr-new bot commented Jul 21, 2024

commit: 8b4edd3

pnpm add https://pkg.pr.new/@tanstack/angular-query-devtools-experimental@7642
pnpm add https://pkg.pr.new/@tanstack/angular-query-experimental@7642
pnpm add https://pkg.pr.new/@tanstack/eslint-plugin-query@7642
pnpm add https://pkg.pr.new/@tanstack/query-async-storage-persister@7642
pnpm add https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@7642
pnpm add https://pkg.pr.new/@tanstack/query-core@7642
pnpm add https://pkg.pr.new/@tanstack/query-devtools@7642
pnpm add https://pkg.pr.new/@tanstack/query-persist-client-core@7642
pnpm add https://pkg.pr.new/@tanstack/query-sync-storage-persister@7642
pnpm add https://pkg.pr.new/@tanstack/react-query@7642
pnpm add https://pkg.pr.new/@tanstack/react-query-devtools@7642
pnpm add https://pkg.pr.new/@tanstack/react-query-next-experimental@7642
pnpm add https://pkg.pr.new/@tanstack/react-query-persist-client@7642
pnpm add https://pkg.pr.new/@tanstack/solid-query@7642
pnpm add https://pkg.pr.new/@tanstack/solid-query-devtools@7642
pnpm add https://pkg.pr.new/@tanstack/solid-query-persist-client@7642
pnpm add https://pkg.pr.new/@tanstack/svelte-query@7642
pnpm add https://pkg.pr.new/@tanstack/svelte-query-devtools@7642
pnpm add https://pkg.pr.new/@tanstack/svelte-query-persist-client@7642
pnpm add https://pkg.pr.new/@tanstack/vue-query@7642
pnpm add https://pkg.pr.new/@tanstack/vue-query-devtools@7642

Open in Stackblitz

More templates

const queryFn = vi.fn<Array<unknown>, unknown>()

queryFn.mockImplementation(async () => {
await sleep(50)
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's get those numbers down:

Suggested change
await sleep(50)
await sleep(10)

Comment on lines +974 to +976
queryClient.prefetchQuery({ queryKey: key, queryFn })
const query = queryCache.find({ queryKey: key })!
await sleep(100)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
queryClient.prefetchQuery({ queryKey: key, queryFn })
const query = queryCache.find({ queryKey: key })!
await sleep(100)
await queryClient.prefetchQuery({ queryKey: key, queryFn })
const query = queryCache.find({ queryKey: key })!

const query = queryCache.find({ queryKey: key })!
await sleep(100)
expect(queryFn).toHaveBeenCalledTimes(1)
await query.fetch()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand why we fetch twice: first with the prefetching, and then with query.fetch. Shouldn't await prefetchQuery(...) be enough to get the query into error state ?

@TkDodo
Copy link
Collaborator

TkDodo commented Jul 26, 2024

some types are not quite right with your mocks, which is why the pipeline fails

@TkDodo
Copy link
Collaborator

TkDodo commented Aug 27, 2024

@TkDodo TkDodo closed this Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The query gets stuck at fetching status when re-fetched data has cycles
3 participants