React Query Devtools retains detached transition targets through bundled Kobalte registry

未关闭
#12,581 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
javascript, react

调研方向

The retention is in the published Devtools bundle, where transitionsByElement and the bundled Kobalte utils 0.9.2 track transition targets on the body. Start from the linked repro's /react/ entry and window.repro.countAliveTargets() after a forced GC, then compare against the standalone Kobalte example. Done means the stopped-event run drops to 0 after GC without breaking active transitions on connected elements, which depends on the upstream Kobalte fix being released into Devtools.

由索引模型根据 Issue 内容生成。

描述

Describe the bug

React Query Devtools 5.107.1 embeds Kobalte's global transition tracking. If an application element stops a native transitionend event from bubbling and is removed after the transition completes, the bundled registry can retain the detached element. The body-level registry tracks application elements outside the Devtools UI too.

In a minimal React app with one stable query and the Devtools panel mounted, 1,000 completed and removed transition targets remain alive after manual Chrome garbage collection. In the normal-event control, 0 remain alive after GC.

The underlying Kobalte issue and proposed fix are:

This report tracks the downstream Devtools impact and eventual inclusion of the upstream fix. The tested published @tanstack/query-devtools bundle includes transitionsByElement and the affected utils 0.9.2 code. Updating an application's separate Kobalte dependency will not replace code already embedded in that bundle.

Your minimal, reproducible example

https://github.com/whatisyourname0/kobalte-transition-retention-repro/tree/e26a70a/react

The repository includes both a standalone Kobalte example at / and the React Query Devtools example at /react/. The React entry does not execute a direct Kobalte import or use a patched dependency. It mounts QueryClientProvider, one stable sample query, and ReactQueryDevtools with initialIsOpen: true.

Steps to reproduce
git clone https://github.com/whatisyourname0/kobalte-transition-retention-repro.git
cd kobalte-transition-retention-repro
git checkout e26a70a
npm ci
npm run dev
  1. Open /react/ on the displayed local origin. Wait until the Devtools panel and Sample query ready appear.
  2. Click Run stopped events. Wait for completion: 1,000 started, 1,000 ended, 1,000 removed, 0 cancelled. These are real CSS transitions; each target stops transitionend propagation, then is removed after completion.
  3. Open Chrome DevTools → Memory → Collect garbage.
  4. Evaluate window.repro.countAliveTargets() in Console: 1000.
  5. Reload, wait for the panel, click Run control, wait for completion, and collect garbage again. The same expression returns 0.
  6. To inspect ownership, take a heap snapshot after the stopped case and inspect detached retention-probe targets and transitionsByElement in the Devtools bundle.

The fixture keeps only WeakRefs once the async run settles and never logs/exports individual targets. A count before GC is not evidence of retention. callbackRan: null on the React page is intentional: it does not import Kobalte's private callback helper. The standalone page separately demonstrates the blocked callback and Map retaining path.

Expected behavior

Removed application elements are released even when completion events do not reach the body-level listener. Active transitions on connected elements continue to be respected.

How often does this bug happen?

Reproduced in the stopped-event run; the normal-event control released all targets.

Screenshots or Videos

Reproduction UI (not a Memory-panel capture):

React Query Devtools reproduction

Platform

macOS 26.7; Chrome 157.0.8103.78.

Tanstack Query adapter

react-query

TanStack Query version

@tanstack/react-query and @tanstack/react-query-devtools: 5.107.1. React / React DOM: 19.3.1. Exact dependencies are locked. Node >=24 to run the fixture.

TypeScript version

Not applicable; the reproduction uses JavaScript.

Additional context

Both React-page cases completed all 1,000 native transitions and removed all targets with no cancellation events. The affected transition has already ended before removal, so removal cannot be expected to emit transitioncancel for it.

The Kobalte-only reproduction has also been compared against the proposed upstream fix (1,000 retained → 0 after GC). The React Devtools reproduction uses the unmodified published Devtools bundle; that candidate comparison has not been repeated against a rebuilt Devtools bundle. This report concerns the demonstrated DOM retention condition, not a claim that Query cache retention or all application memory growth has this cause.

Could you track incorporating the Kobalte fix into a Devtools release once upstream review/release is complete, or advise on a suitable interim mitigation?

主要语言
TypeScript
星标
50.6k
派生
4.2k
平均合并
8 小时 37 分钟
30 天内合并 PR
450

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TanStack/query 的其他 Issue

查看 TanStack/query 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。