Skip to content

Commit

Permalink
fix(query): gracefully handle CancelledError
Browse files Browse the repository at this point in the history
  • Loading branch information
aulneau committed Jul 8, 2021
1 parent b49d38e commit e5b96c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
}
},
"query.js": {
"bundled": 5170,
"minified": 2240,
"gzipped": 686,
"bundled": 5330,
"minified": 2351,
"gzipped": 746,
"treeshaked": {
"rollup": {
"code": 105,
Expand Down
4 changes: 3 additions & 1 deletion src/query/atomWithInfiniteQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
InfiniteData,
InitialDataFunction,
QueryObserverResult,
isCancelledError,
} from 'react-query'
import { atom } from 'jotai'
import type { WritableAtom, Getter } from 'jotai'
Expand Down Expand Up @@ -60,6 +61,7 @@ export function atomWithInfiniteQuery<
>
)()
: options.initialData

const dataAtom = atom<
| InfiniteData<TData | TQueryData>
| Promise<InfiniteData<TData | TQueryData>>
Expand Down Expand Up @@ -87,7 +89,7 @@ export function atomWithInfiniteQuery<
| QueryObserverResult<InfiniteData<TData>, TError>
| { data?: undefined; error: TError }
) => {
if (result.error) {
if (result.error && !isCancelledError(result.error)) {
if (settlePromise) {
settlePromise(null, result.error)
settlePromise = null
Expand Down

0 comments on commit e5b96c0

Please sign in to comment.