mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-07 22:23:57 -05:00
fix(sio): improve io.close() function (#5344)
Before this change, `await io.close();` would resolve before the HTTP server was properly shut down. Related: https://github.com/socketio/socket.io/pull/4971
This commit is contained in:
committed by
Damien Arrachequesne
parent
161be91975
commit
bb0b480d2a
@@ -831,7 +831,16 @@ export class Server<
|
||||
restoreAdapter();
|
||||
|
||||
if (this.httpServer) {
|
||||
this.httpServer.close(fn);
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
this.httpServer.close((err) => {
|
||||
fn && fn(err);
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
fn && fn();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user