From ac3136ac567200da168ff0590ae205839548b7ec Mon Sep 17 00:00:00 2001 From: "Leonardo A. Guimaraes" Date: Sun, 26 Jul 2026 11:41:36 -0300 Subject: [PATCH] fix(query-core): reconnect MutationObserver on resubscribe (StrictMode fix) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add onSubscribe() to MutationObserver to reconnect the observer to an in-progress mutation when the component resubscribes (e.g. React's StrictMode double-mount cycle). Without this, the observer is removed from the mutation's observers list on cleanup and never reconnects, causing isPending to stay true indefinitely. QueryObserver already has the same pattern — this makes MutationObserver consistent with it. --- packages/query-core/src/mutationObserver.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/query-core/src/mutationObserver.ts b/packages/query-core/src/mutationObserver.ts index 21523963ceb..5fbf8059f25 100644 --- a/packages/query-core/src/mutationObserver.ts +++ b/packages/query-core/src/mutationObserver.ts @@ -99,6 +99,14 @@ export class MutationObserver< } } + protected onSubscribe(): void { + if (this.#currentMutation) { + this.#currentMutation.addObserver(this) + this.#updateResult() + this.#notify() + } + } + onMutationUpdate( action: Action, ): void {