Skip to content

Commit d2fef58

Browse files
committed
enhancing server.close with killable
1 parent 0a8f896 commit d2fef58

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ node_modules
66
/coverage
77
*.pem
88
.idea/
9+
.DS_Store

lib/Server.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const del = require('del');
1313
const express = require('express');
1414
const httpProxyMiddleware = require('http-proxy-middleware');
1515
const ip = require('ip');
16+
const killable = require('killable');
1617
const serveIndex = require('serve-index');
1718
const historyApiFallback = require('connect-history-api-fallback');
1819
const selfsigned = require('selfsigned');
@@ -474,6 +475,8 @@ function Server(compiler, options) {
474475
this.listeningApp = http.createServer(app);
475476
}
476477

478+
killable(this.listeningApp);
479+
477480
// Proxy websockets without the initial http request
478481
// https://github.com/chimurai/http-proxy-middleware#external-websocket-upgrade
479482
websocketProxies.forEach(function (wsProxy) {
@@ -610,14 +613,15 @@ Server.prototype.close = function (callback) {
610613
sock.close();
611614
});
612615
this.sockets = [];
613-
this.listeningApp.close(() => {
614-
this.middleware.close(callback);
615-
});
616616

617617
this.contentBaseWatchers.forEach((watcher) => {
618618
watcher.close();
619619
});
620620
this.contentBaseWatchers = [];
621+
622+
this.listeningApp.kill(() => {
623+
this.middleware.close(callback);
624+
});
621625
};
622626

623627
Server.prototype.sockWrite = function (sockets, type, data) {

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"import-local": "^0.1.1",
5555
"internal-ip": "1.2.0",
5656
"ip": "^1.1.5",
57+
"killable": "^1.0.0",
5758
"loglevel": "^1.4.1",
5859
"opn": "^5.1.0",
5960
"portfinder": "^1.0.9",

0 commit comments

Comments
 (0)