From 61ee3bcbcd44aa36dafe01eda21d22d957a0dedf Mon Sep 17 00:00:00 2001 From: zhayujie Date: Sat, 12 Sep 2026 13:31:12 +0800 Subject: [PATCH] fix(web): restore app_module lookup in channel _do_stop PR #3141 dropped the sys/app_module definition in the disconnect path's _do_stop while switching to _live_channel_manager(), but the next line still reads _clear_singleton_cache off app_module. That raised NameError (swallowed by the except), so the singleton cache was never cleared on disconnect. Restore the app_module lookup so cleanup runs again. Co-authored-by: cowagent --- channel/web/web_channel.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/channel/web/web_channel.py b/channel/web/web_channel.py index 7f2b79de..3ff58ed0 100644 --- a/channel/web/web_channel.py +++ b/channel/web/web_channel.py @@ -5893,6 +5893,8 @@ class ChannelsHandler: def _do_stop(): try: + import sys + app_module = sys.modules.get('__main__') or sys.modules.get('app') mgr = _live_channel_manager() clear_fn = getattr(app_module, '_clear_singleton_cache', None) if app_module else None if mgr: