fix(query-core): re-attach MutationObserver to its in-flight mutation… · TanStack/query@969cdeb · GitHub
Skip to content

Commit 969cdeb

Browse files
committed
fix(query-core): re-attach MutationObserver to its in-flight mutation on resubscribe
When the last listener unsubscribes, onUnsubscribe() removes the observer from its current mutation, but resubscribing never added it back. If React tore down and re-established the subscription while a mutation was in flight (StrictMode, <Activity> hide/show, re-suspending boundaries), the mutation settled against an empty observer list and the observer kept serving its frozen 'pending' snapshot forever. Mirror QueryObserver.onSubscribe(): when the first listener subscribes, re-attach to the current mutation and refresh the result in case the mutation settled while detached. Fixes #11171
1 parent 279bb55 commit 969cdeb

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

‎packages/query-core/src/__tests__/mutationObserver.test.tsx‎

Lines changed: 50 additions & 0 deletions

‎packages/query-core/src/mutationObserver.ts‎

Lines changed: 10 additions & 0 deletions

0 commit comments

Comments
 (0)