fix(preact-query): retry on mount for falsy errors when throwOnError returns false - #11375
fix(preact-query): retry on mount for falsy errors when throwOnError returns false#11375S-jooyoung wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughPreact Query now evaluates function-valued ChangesPreact falsy-error retry handling
Merge Risk: ⚪ Minimal · up to Preact Query now evaluates function-valued throwOnError callbacks for failed queries even when the rejection value is falsy, allowing configured remount retries. The change includes targeted regression coverage and is ready to merge. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…returns false `ensurePreventErrorBoundaryRetry` only evaluated a function-valued `throwOnError` when `query.state.error` was truthy. For a query that rejected with a falsy value (e.g. `undefined`), the callback was skipped and the function itself was treated as truthy, so `retryOnMount` was disabled even though `throwOnError` would have returned `false`. Check `query.state.status === 'error'` instead so the callback runs for every failed query. Ports TanStack#11328 to preact-query.
d3a920b to
2b28b22
Compare
🎯 Changes
Ports #11328 (react-query) to
preact-query.Summary
ensurePreventErrorBoundaryRetryinpreact-queryhas the same check as the one fixed for react-query in #11328: a function-valuedthrowOnErrorwas only evaluated whenquery.state.errorwas truthy. For a query that rejected with a falsy value (e.g.Promise.reject()/undefined), the callback was skipped, the function itself was treated as truthy, andretryOnMountwas disabled even thoughthrowOnErrorwould have returnedfalse. This is the preact side of #11327.Changes
packages/preact-query/src/errorBoundaryUtils.ts: checkquery.state.status === 'error'instead of the truthiness ofquery.state.error, so thethrowOnErrorcallback runs for every failed query.packages/preact-query/src/__tests__/useQuery.test.tsx: regression test — a query that rejects withundefined,throwOnError: () => false,retryOnMount: () => truemust refetch on remount (queryFncalled twice).@tanstack/preact-querypatch).Test plan
main(expected "vi.fn()" to be called 2 times, but got 1 times) and passes with the fix.pnpm nx run @tanstack/preact-query:test:lib— 529 passed.pnpm run test:pr --base=upstream/mainfor the affected projects.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact