Fix Failed to call 'Frontend' 'stop' (TypeError: Cannot read properties of null (reading 'clients') error. https://github.com/Koenkk/zigbee2mqtt/issues/16207

This commit is contained in:
Koen Kanters
2023-01-16 19:19:51 +01:00
parent c927b4b935
commit d8501f04eb
+3 -3
View File
@@ -80,11 +80,11 @@ export default class Frontend extends Extension {
override async stop(): Promise<void> {
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));
}