Skip to content

Commit

Permalink
Merge pull request #13531 from bettercalljason/fix-ws-shutdown
Browse files Browse the repository at this point in the history
fix(ws): close existing connections
  • Loading branch information
kamilmysliwiec authored Jun 3, 2024
2 parents 75fa678 + 6893058 commit a7c5cae
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/platform-ws/adapters/ws-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ export class WsAdapter extends AbstractWsAdapter {
client.on(CLOSE_EVENT, callback);
}

public async close(server: any) {
const closeEventSignal = new Promise((resolve, reject) =>
server.close(err => (err ? reject(err) : resolve(undefined))),
);
for (const ws of server.clients) {
ws.terminate();
}
await closeEventSignal;
}

public async dispose() {
const closeEventSignals = Array.from(this.httpServersRegistry)
.filter(([port]) => port !== UNDERLYING_HTTP_SERVER_PORT)
Expand Down

0 comments on commit a7c5cae

Please sign in to comment.