UI freezes during streaming responses — main thread blocked ~1s per render burst (devtools element instrumentation + renderer commit cost)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 42/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- playwright, react, typescript
- 领域
- frontend, performance
调研方向
Start with dist/core/devtools.js at rememberDevToolsElement() and inspect how the devtools enabled flag is set and checked by neighboring hooks. Then profile the production renderer during the reported streamed token updates, focusing on commit, project(), and reconciliation work. Done means the freeze is reproduced and its production cost is traced, with a fix and regression coverage showing the UI remains responsive.
由索引模型根据 Issue 内容生成。
描述
Summary
In an app rendering with @tanstack/redact (0.3.1) as the React runtime, the UI freezes completely at the start of every streamed AI response — both in dev and production. Longtask observer shows ~1s of main-thread blocking concentrated in the response-start window; frame gaps reach ~1.1s.
Environment
@tanstack/redact: 0.3.1react/react-dom: 19.3.1- Vite 8.3.8 +
@tanstack/react-start1.169.x,redact()plugin - Chrome (headless Chromium via Playwright)
Reproduction
Chat UI that re-renders on every streamed token (TanStack AI useChat → store update → message list render). Send any message; the first visible response freezes the entire page for ~1s, then continues.
Evidence
Dev-mode CPU profile (CDP Profiler, 100µs sampling, 6s window from send):
samples=26877 (~2.7s of 6s)
1.06s 39.4% rememberDevToolsElement dist/core/devtools.js:12
0.50s 18.5% (idle)
0.13s 4.7% (garbage collector)
0.10s 3.7% (program)
... reconcile/commit each <1.5%
Longtasks: 3 tasks ≈ 1037ms inside the first 3s of the stream.
Production build: the same freeze reproduces, so the devtools path (compiled out under NODE_ENV=production) is not the whole story — the renderer's per-commit work during high-frequency updates appears to be the remaining cost.
Root cause (dev path)
dist/core/devtools.js → rememberDevToolsElement() runs for every JSX element in dev and captures new Error("react-stack-top-frame") — a full V8 stack trace — for up to 10k elements/sec, unconditionally, even when devToolsMetadata.enabled === false (no __REACT_DEVTOOLS_GLOBAL_HOOK__ connected). Every other devtools hook early-returns on !enabled; this one doesn't. ~100µs per stack capture × thousands of elements per render burst ≈ the observed ~1s block.
Requested fixes
- Gate the
new Error()capture ondevToolsMetadata.enabled(owner/source metadata can still be recorded — it's just WeakMap writes). - Or add a
redact({ devtools: false })-style flag for apps that don't use the DevTools bridge. - Investigate the production path separately: per-commit
commitDevTools/project()work or reconcile cost under token-rate updates — happy to provide a production CPU profile if useful.
Workaround applied — does NOT fix the bug
bun patch gating the capture on enabled reduced rememberDevToolsElement from 39.4% → 8.6% of dev samples, but the streaming freeze persisted in both dev and production. The patch only removes one measurable cost; it does not address the underlying freeze, which reproduces in the production build where this code path doesn't even exist. We removed Redact from the app entirely — the renderer itself needs investigation under streaming/high-frequency-update load.
- 主要语言
- TypeScript
- 星标
- 640
- 派生
- 32
- 平均合并
- 1 小时 15 分钟
- 30 天内合并 PR
- 7
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/redact 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
相似的 Issue
-
bug data-types
难度 2/5 1-3 小时 新手友好度 88/100
ClickHouse/clickhouse-js#1293 ·
维护者通常 1 天内回复
-
area: middleware enhancement good first issue
难度 2/5 1-3 小时 新手友好度 68/100
-
agent/quality testing
难度 1/5 1 小时以内 新手友好度 95/100
维护者通常 1 天内回复
-
GitHub registry install via `gh` credentials rewrites `\u0000`–`\u001f` escapes in source files to `^@`–`^_`可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 92/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
juspay/agent-distro#203 ·
维护者通常 1 天内回复