-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Make sure query is refetched specified number of times #168
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
Make sure query is refetched specified number of times #168
Conversation
I would expect useQuery to refetch data once if retry is set to 1
That's weird, tests are passing on my machine :/ |
Hmm Travis env issue maybe? |
Can you check on your machine? |
Passes 😂 |
Hey Travis, WTF? |
Wait. I got it to fail locally. Try this: const rendered = render(<Page />)
await waitForElement(() => rendered.getByText('error'))
rendered.debug()
// query should fail `retry + 1` times, since first time isn't a "retry"
await waitForElement(() => rendered.getByText('Failed 2 times'))
rendered.debug() |
Looks like it never flushes the |
To minimize the delay i've set |
Oooohhhh, I don't think the |
And I am pretty sure that is desired from the UI/UX standpoint out of the box. |
Yeah, this is fine |
Something still doesn't seem right tho. Try logging out the failureCount in the render function.... |
Oh wait. I forgot to build. I think it's good. This is what I have now: it('should retry specified number of times', async () => {
const queryFn = jest.fn()
queryFn.mockImplementation(() => {
return Promise.reject('Error test')
})
function Page() {
const { status, failureCount } = useQuery('test', queryFn, {
retry: 1,
retryDelay: 1,
})
return (
<div>
<h1>{status}</h1>
<h2>Failed {failureCount} times</h2>
</div>
)
}
const rendered = render(<Page />)
rendered.getByText('loading')
// query should fail `retry + 1` times, since first time isn't a "retry"
await waitForElement(() => rendered.getByText('Failed 2 times'))
rendered.debug()
expect(queryFn).toHaveBeenCalledTimes(2)
}) |
Let's try |
Wow, I had to set 50s timeout to make it pass :D I don't have a better solution for now, at least it works |
That just doesn't seem right though... like something else is wrong. |
Have you tested this in the browser and played with it there? |
Same with tests - they're passing really fast locally. |
That seems really strange. I want to get to the bottom of it. |
I think I found the reason. |
Well, no, they're in isolated workers.... What is going on!!! |
I'd experienced the issue what almost same it. the test passed on my machine but CI failed by timeout. so I had to google and found a solution. if this project use Jest, would you like to try |
@iamchanii Unfortunately that didn't help - 9f46b36 |
I think this is true, looking into this... |
Alright, I found something that might help us debug. Change the queryKey to something other than |
Yeah, I've noticed that too |
Yeah |
I've sent you a link in Twitter DM |
View your CI Pipeline Execution ↗ for commit 22ccd91.
☁️ Nx Cloud last updated this comment at |
If
retry
is set to 1, I would expectuseQuery
to try once again after fail