From d8501f04eb6fb9853aec8be93af701c928373acd Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Mon, 16 Jan 2023 19:19:51 +0100 Subject: [PATCH] Fix `Failed to call 'Frontend' 'stop' (TypeError: Cannot read properties of null (reading 'clients')` error. https://github.com/Koenkk/zigbee2mqtt/issues/16207 --- lib/extension/frontend.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/extension/frontend.ts b/lib/extension/frontend.ts index 0e9497aed..263fe4212 100644 --- a/lib/extension/frontend.ts +++ b/lib/extension/frontend.ts @@ -80,11 +80,11 @@ export default class Frontend extends Extension { override async stop(): Promise { super.stop(); - for (const client of this.wss.clients) { + this.wss?.clients.forEach((client) => { client.send(stringify({topic: 'bridge/state', payload: 'offline'})); client.terminate(); - } - this.wss.close(); + }); + this.wss?.close(); return new Promise((cb: () => void) => this.server.close(cb)); }