GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Mutation.execute() never releases #retryer after settling, unlike Query.fetch() after #11163 · Issue #11216 · TanStack/query

Mutation.execute() never releases #retryer after settling, unlike Query.fetch() after #11163 #11216

New issue
Copy link
New issue
Copy link
Closed
#11218
Closed
Mutation.execute() never releases #retryer after settling, unlike Query.fetch() after #11163#11216
#11218
Copy link

Description

@MILLERMARRU
MILLERMARRU
opened on Aug 18, 2026
Issue body actions

Describe the bug

Mutation.execute() never clears this.#retryer after the mutation settles, unlike Query.fetch(), which just got this exact fix in #11163 (merged today). This means a settled Mutation instance keeps its Retryer (and everything closed over by it: the resolved/rejected result, variables, mutationFnContext) reachable for as long as the Mutation instance itself is retained by MutationCache.

Your minimal, reproducible example

packages/query-core/src/mutation.ts, execute():

} finally {
  this.#mutationCache.runNext(this)
}

Compare with packages/query-core/src/query.ts's fetch() after #11163:

} finally {
  // The settled retryer's promise would otherwise pin this fetch's raw
  // result (a second copy after structural sharing) for the query's lifetime
  if (this.#retryer === retryer) {
    this.#retryer = undefined
  }
  this.scheduleGc()
}

Mutation's finally block only calls runNext, it never sets this.#retryer = undefined.

Steps to reproduce

  1. Look at #11163's changeset/PR description: Query.fetch() left #retryer set after a fetch settled, and the retryer's resolved promise held the raw fetch result, so a query that had refetched held its data twice: once via structural sharing in state.data, and again through the settled retryer's closure. Same shape, same class, different method.
  2. Mutation.execute() builds this.#retryer = createRetryer({...}) the same way Query.fetch() does, awaits this.#retryer.start() inside try, and has a finally block — but that finally only runs this.#mutationCache.runNext(this), it never releases this.#retryer.
  3. MutationCache keeps completed Mutation instances around until gcTime elapses (or indefinitely while an observer/dehydration still references them, per Removable/scheduleGc), so for that whole window the settled retryer (and whatever it closed over) stays reachable through mutation.#retryer, not just through mutation.state.data/variables.

Expected behavior

Same treatment Query.fetch() just got: once the retryer's promise settles, release the reference (guarded by an identity check like if (this.#retryer === retryer), since execute() can in principle be called again on the same instance via continue()).

Additional context

Not filing a PR myself, wanted to flag this mirrors #11163 closely enough that whoever wrote that fix for Query is probably the right person to confirm the same identity-check subtlety applies to Mutation (I don't have full confidence on interaction with continue() re-entering execute() on the same instance).

Activity

  1. TkDodo
    closed this as completedin #11218on Aug 18, 2026
  2. TkDodo
    added a commit that references this issue on Aug 18, 2026

    fix(query-core): release the retryer once a mutation settles (#11218)

    This issue will close once commit 5981771 is merged into the 'main' branch.
    5981771
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.