Skip to content

Commit 59b3169

Browse files
authored
Merge branch 'main' into fix/lit-query-standard-tsup-build
2 parents f8f010c + 47e539a commit 59b3169

11 files changed

Lines changed: 28 additions & 30 deletions

File tree

docs/framework/react/guides/advanced-ssr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ In the SSR guide, we noted that you could get rid of the boilerplate of having `
218218

219219
> NOTE: If you encounter a type error while using async Server Components with TypeScript versions lower than `5.1.3` and `@types/react` versions lower than `18.2.8`, it is recommended to update to the latest versions of both. Alternatively, you can use the temporary workaround of adding `{/* @ts-expect-error Server Component */}` when calling this component inside another. For more information, see [Async Server Component TypeScript Error](https://nextjs.org/docs/app/building-your-application/configuring/typescript#async-server-component-typescript-error) in the Next.js TypeScript docs.
220220
221-
> NOTE: If you encounter an error `Only plain objects, and a few built-ins, can be passed to Server Actions. Classes or null prototypes are not supported.` make sure that you're **not** passing to queryFn a function reference, instead call the function because queryFn args has a bunch of properties and not all of it would be serializable. see [Server Action only works when queryFn isn't a reference](https://github.com/TanStack/query/issues/6264).
221+
> WARNING: We do **not** recommend using Next.js Server Actions to _fetch_ data in a `queryFn`. When called from the client, Server Actions [run serially, not in parallel](https://react.dev/reference/rsc/use-server#caveats), which conflicts with how React Query fetches and refetches queries. This can leave queries stuck in a pending state or cause the action to never run at all (see [#7934](https://github.com/TanStack/query/issues/7934)). Passing a Server Action reference to `queryFn` can also fail with `Only plain objects, and a few built-ins, can be passed to Server Actions...`, since you have to _call_ the action rather than pass it as a reference (see [#6264](https://github.com/TanStack/query/issues/6264)). For fetching data on the client, `fetch` from an API route or use an RPC layer such as tRPC instead. Server Actions remain a good fit for **mutations** (`useMutation`).
222222
223223
### Nesting Server Components
224224

packages/angular-query-experimental/src/__tests__/inject-query.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ describe('injectQuery', () => {
436436

437437
expect(spy).toHaveBeenCalledTimes(2)
438438
// should call queryFn with context containing the new queryKey
439-
expect(spy).toBeCalledWith({
439+
expect(spy).toHaveBeenCalledWith({
440440
client: queryClient,
441441
meta: undefined,
442442
queryKey: key2,

packages/lit-query/src/tests/context-provider.test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe('QueryClientProvider/context', () => {
4646
provider.remove()
4747
await Promise.resolve()
4848

49-
expect(() => useQueryClient()).toThrowError(/No QueryClient available/)
49+
expect(() => useQueryClient()).toThrow(/No QueryClient available/)
5050
})
5151

5252
it('prefers an explicit client in resolveQueryClient', () => {
@@ -76,7 +76,7 @@ describe('QueryClientProvider/context', () => {
7676
providerA.remove()
7777
await Promise.resolve()
7878

79-
expect(() => useQueryClient()).toThrowError(/No QueryClient available/)
79+
expect(() => useQueryClient()).toThrow(/No QueryClient available/)
8080
})
8181

8282
it('throws when multiple different providers make global lookup ambiguous', async () => {
@@ -93,10 +93,8 @@ describe('QueryClientProvider/context', () => {
9393
await providerB.updateComplete
9494

9595
expect(getDefaultQueryClient()).toBeUndefined()
96-
expect(() => useQueryClient()).toThrowError(
97-
/Multiple QueryClients are mounted/,
98-
)
99-
expect(() => resolveQueryClient()).toThrowError(
96+
expect(() => useQueryClient()).toThrow(/Multiple QueryClients are mounted/)
97+
expect(() => resolveQueryClient()).toThrow(
10098
/Multiple QueryClients are mounted/,
10199
)
102100

@@ -112,7 +110,7 @@ describe('QueryClientProvider/context', () => {
112110

113111
it('requires an explicit client before connect', () => {
114112
const provider = document.createElement(tagName) as QueryClientProvider
115-
expect(() => provider.connectedCallback()).toThrowError(
113+
expect(() => provider.connectedCallback()).toThrow(
116114
/No QueryClient available/,
117115
)
118116
})
@@ -195,7 +193,7 @@ describe('QueryClientProvider/context', () => {
195193
)
196194
expect(unmount).toHaveBeenCalledTimes(1)
197195
expect(getDefaultQueryClient()).toBeUndefined()
198-
expect(() => useQueryClient()).toThrowError(/No QueryClient available/)
196+
expect(() => useQueryClient()).toThrow(/No QueryClient available/)
199197
await waitForMissingQueryClient(() => consumer.query())
200198
await expect(consumer.query.refetch()).rejects.toThrow(
201199
/No QueryClient available/,

packages/lit-query/src/tests/mutation-controller.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('createMutationController', () => {
4242
) as ContextMutationHostElement
4343

4444
expect(consumer.mutation().isIdle).toBe(true)
45-
expect(() => consumer.mutation.mutate(1)).toThrowError(
45+
expect(() => consumer.mutation.mutate(1)).toThrow(
4646
/No QueryClient available/,
4747
)
4848
await expect(consumer.mutation.mutateAsync(1)).rejects.toThrow(

packages/preact-query/src/__tests__/useInfiniteQuery.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ describe('useInfiniteQuery', () => {
976976
await vi.advanceTimersByTimeAsync(160)
977977

978978
const expectedCallCount = 3
979-
expect(fetchPage).toBeCalledTimes(expectedCallCount)
979+
expect(fetchPage).toHaveBeenCalledTimes(expectedCallCount)
980980
expect(onAborts).toHaveLength(expectedCallCount)
981981
expect(abortListeners).toHaveLength(expectedCallCount)
982982

@@ -1051,7 +1051,7 @@ describe('useInfiniteQuery', () => {
10511051
await vi.advanceTimersByTimeAsync(160)
10521052

10531053
const expectedCallCount = 2
1054-
expect(fetchPage).toBeCalledTimes(expectedCallCount)
1054+
expect(fetchPage).toHaveBeenCalledTimes(expectedCallCount)
10551055
expect(onAborts).toHaveLength(expectedCallCount)
10561056
expect(abortListeners).toHaveLength(expectedCallCount)
10571057

packages/preact-query/src/__tests__/useQuery.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4954,17 +4954,17 @@ describe('useQuery', () => {
49544954
// // render error state component
49554955
await vi.advanceTimersByTimeAsync(11)
49564956
rendered.getByText('error')
4957-
expect(queryFn).toBeCalledTimes(1)
4957+
expect(queryFn).toHaveBeenCalledTimes(1)
49584958

49594959
// change to enabled to false
49604960
fireEvent.click(rendered.getByLabelText('retry'))
49614961
await vi.advanceTimersByTimeAsync(11)
49624962
rendered.getByText('error')
4963-
expect(queryFn).toBeCalledTimes(1)
4963+
expect(queryFn).toHaveBeenCalledTimes(1)
49644964

49654965
// // change to enabled to true
49664966
fireEvent.click(rendered.getByLabelText('retry'))
4967-
expect(queryFn).toBeCalledTimes(2)
4967+
expect(queryFn).toHaveBeenCalledTimes(2)
49684968
})
49694969

49704970
it('should refetch when query key changed when previous status is error', async () => {

packages/query-async-storage-persister/src/__tests__/asyncThrottle.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('asyncThrottle', () => {
3636
await vi.advanceTimersToNextTimerAsync()
3737
await vi.advanceTimersByTimeAsync(interval)
3838

39-
expect(mockFunc).toBeCalledTimes(2)
39+
expect(mockFunc).toHaveBeenCalledTimes(2)
4040
expect(mockFunc.mock.calls[1]?.[0]).toBe(3)
4141
expect(execTimeStamps.length).toBe(2)
4242
expect(execTimeStamps[1]! - execTimeStamps[0]!).toBeGreaterThanOrEqual(
@@ -68,7 +68,7 @@ describe('asyncThrottle', () => {
6868
await vi.advanceTimersToNextTimerAsync()
6969
await vi.advanceTimersByTimeAsync(interval)
7070

71-
expect(mockFunc).toBeCalledTimes(2)
71+
expect(mockFunc).toHaveBeenCalledTimes(2)
7272
expect(mockFunc.mock.calls[1]?.[0]).toBe(4)
7373
expect(execTimeStamps.length).toBe(2)
7474
expect(execTimeStamps[1]! - execTimeStamps[0]!).toBeGreaterThanOrEqual(
@@ -98,7 +98,7 @@ describe('asyncThrottle', () => {
9898
await vi.advanceTimersByTimeAsync(interval + 10)
9999
await vi.advanceTimersByTimeAsync(interval + 10)
100100

101-
expect(mockFunc).toBeCalledTimes(2)
101+
expect(mockFunc).toHaveBeenCalledTimes(2)
102102
expect(mockFunc.mock.calls[1]?.[0]).toBe(3)
103103
expect(execTimeStamps.length).toBe(2)
104104
expect(execTimeStamps[1]! - execTimeStamps[0]!).toBeGreaterThanOrEqual(
@@ -126,7 +126,7 @@ describe('asyncThrottle', () => {
126126
new Promise((resolve) => testFunc(2, resolve))
127127
await vi.advanceTimersByTimeAsync(interval)
128128

129-
expect(mockFunc).toBeCalledTimes(2)
129+
expect(mockFunc).toHaveBeenCalledTimes(2)
130130
expect(mockFunc.mock.calls[1]?.[0]).toBe(2)
131131
})
132132

packages/react-query/src/__tests__/useInfiniteQuery.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ describe('useInfiniteQuery', () => {
977977
await vi.advanceTimersByTimeAsync(160)
978978

979979
const expectedCallCount = 3
980-
expect(fetchPage).toBeCalledTimes(expectedCallCount)
980+
expect(fetchPage).toHaveBeenCalledTimes(expectedCallCount)
981981
expect(onAborts).toHaveLength(expectedCallCount)
982982
expect(abortListeners).toHaveLength(expectedCallCount)
983983

@@ -1052,7 +1052,7 @@ describe('useInfiniteQuery', () => {
10521052
await vi.advanceTimersByTimeAsync(160)
10531053

10541054
const expectedCallCount = 2
1055-
expect(fetchPage).toBeCalledTimes(expectedCallCount)
1055+
expect(fetchPage).toHaveBeenCalledTimes(expectedCallCount)
10561056
expect(onAborts).toHaveLength(expectedCallCount)
10571057
expect(abortListeners).toHaveLength(expectedCallCount)
10581058

packages/react-query/src/__tests__/useQuery.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4933,17 +4933,17 @@ describe('useQuery', () => {
49334933
// // render error state component
49344934
await vi.advanceTimersByTimeAsync(11)
49354935
rendered.getByText('error')
4936-
expect(queryFn).toBeCalledTimes(1)
4936+
expect(queryFn).toHaveBeenCalledTimes(1)
49374937

49384938
// change to enabled to false
49394939
fireEvent.click(rendered.getByLabelText('retry'))
49404940
await vi.advanceTimersByTimeAsync(11)
49414941
rendered.getByText('error')
4942-
expect(queryFn).toBeCalledTimes(1)
4942+
expect(queryFn).toHaveBeenCalledTimes(1)
49434943

49444944
// // change to enabled to true
49454945
fireEvent.click(rendered.getByLabelText('retry'))
4946-
expect(queryFn).toBeCalledTimes(2)
4946+
expect(queryFn).toHaveBeenCalledTimes(2)
49474947
})
49484948

49494949
it('should refetch when query key changed when previous status is error', async () => {

packages/solid-query/src/__tests__/useInfiniteQuery.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ describe('useInfiniteQuery', () => {
11351135
await vi.advanceTimersByTimeAsync(160)
11361136

11371137
const expectedCallCount = 3
1138-
expect(fetchPage).toBeCalledTimes(expectedCallCount)
1138+
expect(fetchPage).toHaveBeenCalledTimes(expectedCallCount)
11391139
expect(onAborts).toHaveLength(expectedCallCount)
11401140
expect(abortListeners).toHaveLength(expectedCallCount)
11411141

@@ -1216,7 +1216,7 @@ describe('useInfiniteQuery', () => {
12161216
await vi.advanceTimersByTimeAsync(160)
12171217

12181218
const expectedCallCount = 2
1219-
expect(fetchPage).toBeCalledTimes(expectedCallCount)
1219+
expect(fetchPage).toHaveBeenCalledTimes(expectedCallCount)
12201220
expect(onAborts).toHaveLength(expectedCallCount)
12211221
expect(abortListeners).toHaveLength(expectedCallCount)
12221222

0 commit comments

Comments
 (0)