initial_messages leaks messages across sessions: the mutable Field.default list is shared by every State instance

未关闭 适合新手
#61 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@FarhanAliRaza 已经在做这个了。

开始于 2026年10月30日。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

从 initial_messages 的处理和 thirdparty_a2/probes/mutable_default_probe 中的可变默认值探测开始;issue 没有指出应用源文件或测试。先运行双上下文聊天复现,检查独立的状态实例是否仍共享同一个列表。完成标准是每个会话在 /chat-initial 和 /chat 中只能看到自己的消息。

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

描述

Severity: MEDIUM, pre-existing (reflex 0.9.12, 0.10.0a1 and 0.10.0a2 with reflex-chat 0.0.2a1).

Two browser sessions: session B sees session A's /chat-initial message (on 0.9.12 the leak also reaches /chat). The list passed as initial_messages ends up as a mutable Field.default that every state instance shares, so one session's appends are visible to all. Use a default factory / copy the list per instance.

Repro: thirdparty_a2/probes/mutable_default_probe and the tp_components chat page driven in two contexts; evidence thirdparty_a2/out/components/*-chat-leak.txt in https://github.com/reflex-dev/reflex/blob/claude/reflex-prerelease-testing-t0sd90/prerelease_testing/2026-10-07/thirdparty_a2/NOTES.md (finding F-009 of the 2026-10-06 pre-release QA, re-verified on 2026-10-07).

主要语言
Python
星标
342
派生
84
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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