← 返回首页
fix(query-broadcast-client-experimental): suppress unhandled postMessage DataCloneError rejections by algojogacor · Pull Request #10697 · TanStack/query · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

fix(query-broadcast-client-experimental): suppress unhandled postMessage DataCloneError rejections#10697

Open
algojogacor wants to merge 1 commit into
TanStack:mainfrom
algojogacor:fix/broadcast-postmessage-catch
Open

fix(query-broadcast-client-experimental): suppress unhandled postMessage DataCloneError rejections#10697
algojogacor wants to merge 1 commit into
TanStack:mainfrom
algojogacor:fix/broadcast-postmessage-catch

Conversation

Copy link
Copy Markdown

Summary

Fixes #10543

broadcastQueryClient silently causes unhandled DataCloneError rejections when a query's state.data contains non-cloneable values like ReadableStream, Response, File, or framework proxies. These rejections surface in error trackers (Sentry/Datadog) with stacks pointing into node_modules, making them impossible to trace to specific queries.

Root Cause

In packages/query-broadcast-client-experimental/src/index.ts, the three channel.postMessage() calls (lines 40, 49, 57 — for updated, removed, added events) do not have .catch() handlers. When the structured-clone algorithm encounters non-cloneable data, broadcast-channel rejects internally, producing an unhandledrejection event.

Fix

Added .catch(() => {}) to all three postMessage() calls. This silently swallows clone failures — the same approach used by broadcast-channel internally for its own message parsing. Cross-tab sync for that specific query update is skipped (the cloned data can't be transferred), but error trackers are no longer polluted and other queries continue syncing normally.

Changes

  • packages/query-broadcast-client-experimental/src/index.ts: added .catch(() => {}) to three postMessage() calls (+3 -3 lines)

Testing

  • Non-cloneable data in query state: broadcastQueryClient no longer triggers unhandledrejection when setting query data with ReadableStream or Response values ✅
  • Normal broadcast: cloneable data (strings, numbers, plain objects) continues to sync across tabs as before ✅
  • Multiple queries: only the query with non-cloneable data has its broadcast silently dropped; other queries continue syncing normally ✅

…age DataCloneError rejections Add .catch() handlers to all three BroadcastChannel postMessage calls to prevent unhandledrejection events when query state contains non-cloneable values (ReadableStream, Response, File, functions, etc.). Fixes TanStack#10543
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

[query-broadcast-client-experimental] postMessage failures surface as unhandled DataCloneError rejections

1 participant

Footer

© 2026 GitHub, Inc.