浏览代码

avoid `KeyError` in `handle_disconnect` (fixes #4304)

Falko Schindler 3 月之前
父节点
当前提交
8352638efc
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      nicegui/client.py

+ 2 - 0
nicegui/client.py

@@ -257,6 +257,8 @@ class Client:
         In contrast to connect handlers, disconnect handlers are not called during a reconnect.
         This behavior should be fixed in version 3.0.
         """
+        if socket_id not in self._socket_to_document_id:
+            return
         document_id = self._socket_to_document_id.pop(socket_id)
         self._cancel_delete_task(document_id)
         self._num_connections[document_id] -= 1