Skip to content

Commit bb0b480

Browse files
fantuadarrachequesne
authored andcommitted
fix(sio): improve io.close() function (#5344)
Before this change, `await io.close();` would resolve before the HTTP server was properly shut down. Related: #4971
1 parent 161be91 commit bb0b480

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/socket.io/lib/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,16 @@ export class Server<
831831
restoreAdapter();
832832

833833
if (this.httpServer) {
834-
this.httpServer.close(fn);
834+
await new Promise<void>((resolve, reject) => {
835+
this.httpServer.close((err) => {
836+
fn && fn(err);
837+
if (err) {
838+
reject(err);
839+
} else {
840+
resolve();
841+
}
842+
});
843+
});
835844
} else {
836845
fn && fn();
837846
}

0 commit comments

Comments
 (0)