mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-12 00:17:56 -05:00
Compare commits
2 Commits
fix/esm-ht
...
fix/server
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4176a812ce | ||
|
|
2cd6d591dc |
@@ -831,14 +831,13 @@ export class Server<
|
||||
restoreAdapter();
|
||||
|
||||
if (this.httpServer) {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
return new Promise<void>((resolve) => {
|
||||
this.httpServer.close((err) => {
|
||||
fn && fn(err);
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
debug("server was not running");
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -70,6 +70,27 @@ describe("close", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("should not throw when the underlying HTTP server is not running (callback)", (done) => {
|
||||
const httpServer = createServer();
|
||||
const io = new Server(httpServer);
|
||||
|
||||
io.close((err) => {
|
||||
expect((err as Error & { code: string }).code).to.eql(
|
||||
"ERR_SERVER_NOT_RUNNING",
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("should not throw when the underlying HTTP server is not running (Promise)", (done) => {
|
||||
const httpServer = createServer();
|
||||
const io = new Server(httpServer);
|
||||
|
||||
io.close()
|
||||
.then(() => done())
|
||||
.catch((e) => done(e));
|
||||
});
|
||||
|
||||
describe("graceful close", () => {
|
||||
function fixture(filename) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user