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)); }