From 6bf148e12b00a3ec596f4c123ec35445a48ab209 Mon Sep 17 00:00:00 2001 From: kylo5aby <109658203+zhenweijin@users.noreply.github.com> Date: Tue, 27 Feb 2024 00:07:39 +0800 Subject: [PATCH] http: fix `close` return value mismatch between doc and implementation PR-URL: https://github.com/nodejs/node/pull/51797 Fixes: https://github.com/nodejs/node/issues/51787 Reviewed-By: Paolo Insogna Reviewed-By: Robert Nagy Reviewed-By: Ethan Arrowood Reviewed-By: Matteo Collina Reviewed-By: Luigi Pinca Reviewed-By: Marco Ippolito --- lib/_http_server.js | 1 + lib/https.js | 1 + test/parallel/test-http-server.js | 1 + 3 files changed, 3 insertions(+) diff --git a/lib/_http_server.js b/lib/_http_server.js index edf951f8946c40..2da05745327d90 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -561,6 +561,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); });