Skip to content

fix(preact-query): retry on mount for falsy errors when throwOnError returns false - #11375

Open
S-jooyoung wants to merge 1 commit into
TanStack:mainfrom
S-jooyoung:fix/preact-falsy-error-retry-on-mount
Open

fix(preact-query): retry on mount for falsy errors when throwOnError returns false#11375
S-jooyoung wants to merge 1 commit into
TanStack:mainfrom
S-jooyoung:fix/preact-falsy-error-retry-on-mount

Conversation

@S-jooyoung

@S-jooyoung S-jooyoung commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🎯 Changes

Ports #11328 (react-query) to preact-query.

Summary

ensurePreventErrorBoundaryRetry in preact-query has the same check as the one fixed for react-query in #11328: a function-valued throwOnError was only evaluated when query.state.error was 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, and retryOnMount was disabled even though throwOnError would have returned false. This is the preact side of #11327.

Changes

  • packages/preact-query/src/errorBoundaryUtils.ts: check query.state.status === 'error' instead of the truthiness of query.state.error, so the throwOnError callback runs for every failed query.
  • packages/preact-query/src/__tests__/useQuery.test.tsx: regression test — a query that rejects with undefined, throwOnError: () => false, retryOnMount: () => true must refetch on remount (queryFn called twice).
  • changeset (@tanstack/preact-query patch).

Test plan

  • The new test fails on 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/main for the affected projects.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: d14d8e6e-991e-4f0c-9e4d-722997c18f7c

📥 Commits

Reviewing files that changed from the base of the PR and between fe77cdc and d3a920b.

📒 Files selected for processing (3)
  • .changeset/preact-falsy-error-retry-on-mount.md
  • packages/preact-query/src/__tests__/useQuery.test.tsx
  • packages/preact-query/src/errorBoundaryUtils.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Preact Query now evaluates function-valued throwOnError for error states, including falsy errors. A regression test covers retry on remount, and a patch changeset documents the behavior.

Changes

Preact falsy-error retry handling

Layer / File(s) Summary
Error-boundary retry behavior
packages/preact-query/src/errorBoundaryUtils.ts, packages/preact-query/src/__tests__/useQuery.test.tsx, .changeset/preact-falsy-error-retry-on-mount.md
ensurePreventErrorBoundaryRetry evaluates throwOnError when the query status is error and passes the query error and query instance to the handler. The regression test verifies retry after remount for a falsy error. The changeset records the patch release.
Estimated code review effort: 2 (Simple) ~10 minutes

Merge Risk: ⚪ Minimal · up to d3a92

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: tkdodo

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the primary fix: enabling retry on mount for falsy errors when throwOnError returns false.
Description check ✅ Passed The description follows the repository template. It explains the motivation, lists the affected files and behavior, documents testing, and completes the checklist and release impact sections.
Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…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.
@S-jooyoung
S-jooyoung force-pushed the fix/preact-falsy-error-retry-on-mount branch from d3a920b to 2b28b22 Compare September 3, 2026 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant