Skip to content

Commit 8be9d94

Browse files
committed
updated close function for safety
1 parent a3d0219 commit 8be9d94

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/http-proxy/index.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,16 @@ ProxyServer.prototype.listen = function(port, hostname) {
134134

135135
ProxyServer.prototype.close = function(callback) {
136136
if (this._server) {
137-
this._server.close(callback);
138-
this._server = null;
137+
// Wrap callback to nullify server after all open connections are closed.
138+
var callback_wrapper = function() {
139+
this._server = null;
140+
141+
if (callback) {
142+
callback(arguments);
143+
}
144+
};
145+
146+
this._server.close(callback_wrapper);
139147
}
140148
};
141149

0 commit comments

Comments
 (0)