Describe the bug
react-query fixed this in #9338 (reported in #9336): ensurePreventErrorBoundaryRetry now evaluates a function-form throwOnError against the actual query error before deciding to set retryOnMount = false.
preact-query's copy of ensurePreventErrorBoundaryRetry is still the pre-#9338 version — it treats any function as truthy:
// packages/preact-query/src/errorBoundaryUtils.ts
if (
options.suspense ||
options.throwOnError || // <- a function that returns false still passes this check
options.experimental_prefetchInRender
) {
if (!errorResetBoundary.isReset()) {
options.retryOnMount = false
}
}
So with throwOnError: () => false (or a predicate like (error) => error.status >= 500 that returns false for the current error), an errored query is not retried on remount, even though the error was never thrown to an error boundary. Both useBaseQuery and useQueries call sites pass the 2-arg form, so the query's actual error state is never consulted.
Reproduction
Porting the three regression tests from #9338 into packages/preact-query/src/__tests__/useQuery.test.tsx on current main:
- ❌
should retry on mount when throwOnError returns false — fails (expected 1 to be 2 fetches; the remount never refetches)
- ❌
should handle throwOnError function based on actual error state — fails (same)
- ✅
should not retry on mount when throwOnError function returns true — passes
Expected behavior
Same as react-query after #9338: a function-form throwOnError should only prevent retryOnMount when it actually returns true for the query's current error.
Additional context
Found while diffing react-query ↔ preact-query for parity — same class of drift as #11155 (a react-query fix that didn't make it into the preact mirror). The port is mechanical (errorBoundaryUtils.ts + the two call sites + the #9338 tests); I have it ready and will open a PR.
Describe the bug
react-query fixed this in #9338 (reported in #9336):
ensurePreventErrorBoundaryRetrynow evaluates a function-formthrowOnErroragainst the actual query error before deciding to setretryOnMount = false.preact-query's copy of
ensurePreventErrorBoundaryRetryis still the pre-#9338 version — it treats any function as truthy:So with
throwOnError: () => false(or a predicate like(error) => error.status >= 500that returnsfalsefor the current error), an errored query is not retried on remount, even though the error was never thrown to an error boundary. BothuseBaseQueryanduseQueriescall sites pass the 2-arg form, so the query's actual error state is never consulted.Reproduction
Porting the three regression tests from #9338 into
packages/preact-query/src/__tests__/useQuery.test.tsxon currentmain:should retry on mount when throwOnError returns false— fails (expected 1 to be 2fetches; the remount never refetches)should handle throwOnError function based on actual error state— fails (same)should not retry on mount when throwOnError function returns true— passesExpected behavior
Same as react-query after #9338: a function-form
throwOnErrorshould only preventretryOnMountwhen it actually returnstruefor the query's current error.Additional context
Found while diffing
react-query↔preact-queryfor parity — same class of drift as #11155 (a react-query fix that didn't make it into the preact mirror). The port is mechanical (errorBoundaryUtils.ts+ the two call sites + the #9338 tests); I have it ready and will open a PR.