Skip to content

Commit ff830db

Browse files
authored
fix(devtools): fix devtools crash on rejected promises on refetch (TanStack#2344)
Catch the error using noop when refetching the query via devtools fixes TanStack#2014
1 parent 2b8d2af commit ff830db

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/devtools/devtools.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { ThemeProvider, defaultTheme as theme } from './theme'
2121
import { getQueryStatusLabel, getQueryStatusColor } from './utils'
2222
import Explorer from './Explorer'
2323
import Logo from './Logo'
24+
import { noop } from '../core/utils'
2425

2526
interface DevtoolsOptions {
2627
/**
@@ -384,6 +385,11 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
384385
return undefined
385386
}, [isOpen, sort, sortFn, sortDesc, setUnsortedQueries, queryCache])
386387

388+
const handleRefetch = () => {
389+
const promise = activeQuery.fetch()
390+
promise.catch(noop)
391+
}
392+
387393
return (
388394
<ThemeProvider theme={theme}>
389395
<Panel
@@ -710,7 +716,7 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
710716
>
711717
<Button
712718
type="button"
713-
onClick={() => activeQuery.fetch()}
719+
onClick={handleRefetch}
714720
disabled={activeQuery.state.isFetching}
715721
style={{
716722
background: theme.active,

0 commit comments

Comments
 (0)