Skip to content

Commit 078feb1

Browse files
fix: code
1 parent 1bae63b commit 078feb1

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

lib/Server.js

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,17 +1775,25 @@ class Server {
17751775
}
17761776

17771777
async stop() {
1778+
if (this.webSocketProxies.length > 0) {
1779+
this.webSocketProxies = [];
1780+
}
1781+
1782+
if (this.staticWatchers.length > 0) {
1783+
await Promise.all(this.staticWatchers.map((watcher) => watcher.close()));
1784+
1785+
this.staticWatchers = [];
1786+
}
1787+
17781788
if (this.webSocketServer) {
17791789
await new Promise((resolve) => {
17801790
this.webSocketServer.implementation.close(() => {
17811791
resolve();
17821792
});
17831793
});
1784-
}
1785-
1786-
await Promise.all(this.staticWatchers.map((watcher) => watcher.close()));
17871794

1788-
this.staticWatchers = [];
1795+
this.webSocketServer = null;
1796+
}
17891797

17901798
if (this.server) {
17911799
await new Promise((resolve) => {
@@ -1794,17 +1802,23 @@ class Server {
17941802
});
17951803
});
17961804

1797-
await new Promise((resolve, reject) => {
1798-
this.middleware.close((error) => {
1799-
if (error) {
1800-
reject(error);
1805+
this.server = null;
18011806

1802-
return;
1803-
}
1807+
if (this.middleware) {
1808+
await new Promise((resolve, reject) => {
1809+
this.middleware.close((error) => {
1810+
if (error) {
1811+
reject(error);
18041812

1805-
resolve();
1813+
return;
1814+
}
1815+
1816+
resolve();
1817+
});
18061818
});
1807-
});
1819+
1820+
this.middleware = null;
1821+
}
18081822
}
18091823
}
18101824

0 commit comments

Comments
 (0)