[BUG] Setting children to None leaves removed components registered: their callbacks keep firing and the subtree can never be mounted again
維護者通常 2 天內回覆
評估
研究方向
Start with the callback and component-removal path exercised by the toggle and update_view callbacks in the reproduction. Compare the lifecycle when children returns None with the working [] case, then verify that removed components stop generating requests and that mounting the view again restores it without a page reload.
由索引模型根據 Issue 內容生成。
描述
Summary: if a callback removes a subtree by returning children=None, the removed components stay registered: callbacks targeting them keep firing, and the subtree can never be rendered again. Returning [] works correctly.
Describe your context
dash 4.4.1 (same on 4.5.0rc0, 4.0.0, 3.3.0, 2.18.2)
plotly 6.6.0
- Python 3.10, Windows 11, Microsoft Edge 154 (Chromium)
- Same with
debug=Trueanddebug=False, no error in the console or the dev tools
Describe the bug
from dash import Dash, Input, Output, ctx, dcc, html
app = Dash(__name__, suppress_callback_exceptions=True)
app.layout = html.Div([
dcc.Interval(id="tick", interval=1000),
html.Button("Mount", id="mount"),
html.Button("Unmount", id="unmount"),
html.Div(id="container"),
])
@app.callback(
Output("container", "children"),
Input("mount", "n_clicks"),
Input("unmount", "n_clicks"),
prevent_initial_call=True,
)
def toggle(_mount, _unmount):
if ctx.triggered_id == "mount":
return html.Div(id="view", children=html.Div(id="view-tick"))
return None # returning [] instead works as expected
@app.callback(Output("view-tick", "children"), Input("tick", "n_intervals"))
def update_view(n):
print(f"update_view called, n_intervals={n}", flush=True)
return f"tick {n}"
if __name__ == "__main__":
app.run(debug=False)
- Click Mount:
tick Nis displayed,update_viewruns every second. Correct. - Click Unmount: the text disappears, but the browser keeps sending
update_viewrequests every second (visible in the server log). - Click Mount again: the
togglerequest returns the subtree (HTTP 200), but#viewnever appears in the DOM, until the page is reloaded.
With return [] in toggle, step 2 sends no request and step 3 displays the view again.
Expected behavior
None and [] should both remove the subtree: no more callbacks for the removed components, and the subtree can be mounted again.
- 主要語言
- Python
- 星號
- 24.4k
- 分支
- 2.3k
- 平均合併
- 2 天 5 小時
- 30 天內合併 PR
- 22
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
plotly/dash 的其他 Issue
-
P2 plotly-internal size: 1 task
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 2 天內回覆
-
Extract graph schema validation into properly named test可能已有人在做 @Nice6042 於 56 天前認領。 未關閉good first issue P3 size: 1 task
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 2 天內回覆
-
[BUG] dcc.Dropdown: hidden focus-target input is focusable inside aria-hidden and can overflow its wrapper可能已有人在做 @KoolADE85 於 3 天前認領。 未關閉bug P2 size: 1
難度 4/5 3-5 天 新手友好度 56/100
plotly/dash#4042 · 3 則留言 · 已指派 1 人 ·
維護者通常 2 天內回覆
-
P3 plotly-internal size: 10+ task
難度 5/5 一週以上 新手友好度 30/100
維護者通常 2 天內回覆
-
P2 plotly-internal size: 5 task
難度 4/5 3-5 天 新手友好度 35/100
維護者通常 2 天內回覆
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 85/100
Deepak3699/Ai_Mentor#244 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
btclib-org/btclib-node#1880 ·
維護者通常 1 天內回覆
-
CONTRIBUTING.md: say how ticketless bug fixes and feature PRs are handled可能已有人在做 @khuisman 今天認領。 未關閉v0.9.2
難度 1/5 1 小時以內 新手友好度 84/100
khuisman/mcp-gee-sweet#941 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
pyjanitor-devs/pyjanitor#1758 ·
維護者通常 1 天內回覆
-
bug ready for review
難度 2/5 1-3 小時 新手友好度 86/100
odysseus-dev/odysseus#6641 ·
維護者通常 1 天內回覆