Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,11 @@ describe('PersistQueryClientProvider', () => {
function Page() {
const state = useQuery({
queryKey: key,
queryFn: () =>
sleep(10).then(() => {
fetched = true
return 'fetched'
}),

queryFn: async () => {
await sleep(10)
fetched = true
return 'fetched'
},
Comment on lines +387 to +391
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟑 Minor

Inconsistent PR description, but changes align with learnings.

The PR title and description claim to "replace 'await sleep' with 'sleep().then()' pattern in restoreClient", but the actual change here is in a queryFn and goes in the opposite direction (from .then() to async/await).

However, the change itself is appropriate: the queryFn has a side effect (fetched = true), so async/await syntax is preferred for clarity.

Based on learnings, please update the PR title and description to accurately reflect the actual changes.

πŸ€– Prompt for AI Agents
In
packages/react-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx
around lines 387 to 391, the PR title/description incorrectly state "replace
'await sleep' with 'sleep().then()' pattern in restoreClient" while the actual
change in this test replaces a .then() style sleep with an async/await queryFn
(which is correct due to the side effect). Update the PR title and description
to accurately describe the change (e.g., "use async/await in queryFn with side
effect in PersistQueryClientProvider tests" or similar) and remove any
references to modifying restoreClient or switching to .then() so they match the
code changes.

staleTime: Infinity,
})

Expand All @@ -415,6 +414,8 @@ describe('PersistQueryClientProvider', () => {
expect(rendered.getByText('data: null')).toBeInTheDocument()
await act(() => vi.advanceTimersByTimeAsync(10))
expect(rendered.getByText('data: hydrated')).toBeInTheDocument()
await act(() => vi.advanceTimersByTimeAsync(11))
expect(rendered.getByText('data: hydrated')).toBeInTheDocument()

expect(states).toHaveLength(2)

Expand Down
Loading