Skip to content

Commit

Permalink
fix: close the adapters when the server is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
darrachequesne committed Feb 23, 2024
1 parent 748e18c commit bf64870
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,13 +742,17 @@ export class Server<
* @param [fn] optional, called as `fn([err])` on error OR all conns closed
*/
public close(fn?: (err?: Error) => void): void {
for (const socket of this.sockets.sockets.values()) {
socket._onclose("server shutting down");
}
this._nsps.forEach((nsp) => {
nsp.sockets.forEach((socket) => {
socket._onclose("server shutting down");
});

nsp.adapter.close();
});

this.engine.close();

// restore the Adapter prototype
// restore the Adapter prototype, when the Socket.IO server was attached to a uWebSockets.js server
restoreAdapter();

if (this.httpServer) {
Expand Down

0 comments on commit bf64870

Please sign in to comment.