Render logger throws SecurityError on a cross-origin iframe, corrupting React's scheduler
还没有人认领这个 Issue。
- 主要语言
- TypeScript
- 星标
- 499
- 派生
- 100
- 平均合并
- 1 天 17 小时
- 30 天内合并 PR
- 4
描述
Summary
When a page mounts a cross-origin iframe, the devtools' render logger walks into it and throws a SecurityError. That leaves React's fiber scheduler in a bad state, and from then on controlled inputs stop committing anywhere on the page for the rest of that page load.
The visible symptom is not a devtools error — it's that typing into any <input> in the app silently does nothing. That makes it expensive to diagnose: the app looks fine, and the failure appears to be in whatever component you happen to be working on.
Versions
@tanstack/react-devtools0.10.7@tanstack/devtools-vite0.8.0- React 19, TanStack Start, Vite 8, dev mode only (devtools are
import.meta.env.DEV-gated)
Reproduction
- Mount
<TanStackDevtools>in the root route, gated onimport.meta.env.DEV. - Anywhere in the authenticated tree, mount a component that injects a cross-origin iframe. In our case it is the Spotify Web Playback SDK (
https://sdk.scdn.co/spotify-player.js), which creates its own iframe. - Load any page under that tree in dev.
- Type into any controlled input.
Observed console output, in order:
SecurityError: Failed to read a named property from 'Window': Blocked a frame with
origin "http://127.0.0.1:3939" from accessing a cross-origin frame.
then
Error: Should not already be working.
After the second error, controlled-input commits fail for the remainder of the page load — including inputs entirely unrelated to the iframe, such as a login form on a different route.
Workaround
Blocking the third-party script prevents the iframe from being created, and everything behaves normally:
await page.route('**sdk.scdn.co/**', (r) => r.abort())
Not mounting the iframe-owning component in dev also works. Both are avoidance rather than fixes.
Suggested fix
Guard the render logger's DOM traversal so a cross-origin frame is skipped rather than entered — accessing a frame's contentWindow properties should be wrapped, or iframe elements whose origin differs should be excluded from the walk. A third-party embed (payment, video, audio SDK, maps) is common enough that any app with one plus these devtools will hit this.
Happy to test a patch against the repro above.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 render logger 的 DOM 遍历开始,在 React 19 开发环境中使用 cross-origin iframe(例如 Spotify Web Playback SDK iframe)复现该问题。跟踪 SecurityError 及其后续的 scheduler error,然后验证 iframe 挂载后 controlled inputs 仍然会 commit。cross-origin frame 能够被安全跳过,且 repro 不再破坏 input commits,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- react, typescript
- 领域
- devtools, frontend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 68/100