diff --git a/lib/_http_server.js b/lib/_http_server.js index bfeb790bb3b6c3..2cddb8cf04d529 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -570,6 +570,7 @@ ObjectSetPrototypeOf(Server, net.Server); Server.prototype.close = function() { httpServerPreClose(this); ReflectApply(net.Server.prototype.close, this, arguments); + return this; }; Server.prototype[SymbolAsyncDispose] = async function() { diff --git a/lib/https.js b/lib/https.js index ca8c49d5bef319..f356429b963152 100644 --- a/lib/https.js +++ b/lib/https.js @@ -111,6 +111,7 @@ Server.prototype.setTimeout = HttpServer.prototype.setTimeout; Server.prototype.close = function() { httpServerPreClose(this); ReflectApply(tls.Server.prototype.close, this, arguments); + return this; }; Server.prototype[SymbolAsyncDispose] = async function() { diff --git a/test/parallel/test-http-server.js b/test/parallel/test-http-server.js index b93258b198afe1..4ccb77c89a981f 100644 --- a/test/parallel/test-http-server.js +++ b/test/parallel/test-http-server.js @@ -139,4 +139,5 @@ process.on('exit', function() { assert.match(server_response, quit); assert.strictEqual(client_got_eof, true); + assert.strictEqual(server.close(), server); });