fix(query-persist-client-core): catch persist errors in the subscriber by mgarcia-improving · Pull Request #11718 · TanStack/query · GitHub
Skip to content

fix(query-persist-client-core): catch persist errors in the subscriber - #11718

Open
mgarcia-improving wants to merge 1 commit into
TanStack:mainfrom
mgarcia-improving:issue-11663
Open

mgarcia-improving wants to merge 1 commit into
TanStack:mainfrom
mgarcia-improving:issue-11663

Conversation

@mgarcia-improving

@mgarcia-improving mgarcia-improving commented Sep 28, 2026 •

Copy link
Copy Markdown

🎯 Changes

persistQueryClientSubscribe called persistQueryClientSave and ignored the promise. When a custom persister rejected, or a dehydrateOptions callback threw, that became an unhandled rejection on each cache update.

The subscriber now catches that error. In development it logs it, the same way restore does. Calling persistQueryClientSave directly still rejects, so callers that await it are unchanged.

Fixes #11663.

There is another open PR for this, #11678. This is a separate take on the same fix.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm nx run @tanstack/query-persist-client-core:test:lib (58 passed). I did not run the full pnpm run test:pr suite.
  • I have followed the AI contribution policy and 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).

Summary by CodeRabbit

  • Bug Fixes
    • Persistence failures and errors during query dehydration are now caught, preventing unhandled rejections when saving persisted query data.
    • In non-production environments, these failures are logged for troubleshooting.

A failing persister or dehydrate callback was an unhandled rejection because persistQueryClientSubscribe dropped the save promise.
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

This branch has not been deployed

No deployments
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.

persistQueryClientSubscribe drops the persistQueryClientSave promise, causing unhandled rejections when persisting fails

2 participants