Commit c87d92cc389 for nodejs
commit c87d92cc389c5a076319ac3fb1ba3bf9438ddfa5
Author: Yuya Inoue <65857152+inoway46@users.noreply.github.com>
Date: Fri Dec 4 22:32:31 2026 +0900
http2: fix `await using` for cleartext servers with idle sessions
Call this.close() so disposal also closes existing HTTP/2 sessions.
Calling the parent close method could leave disposal waiting for an
idle client to disconnect.
Assisted-by: Codex
Signed-off-by: inoway46 <inoueyuya416@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67967
Fixes: https://github.com/nodejs/node/issues/67966
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js
index 2290af5d998..dfee55b2e50 100644
--- a/lib/internal/http2/core.js
+++ b/lib/internal/http2/core.js
@@ -3916,7 +3916,7 @@ class Http2Server extends NETServer {
}
async [SymbolAsyncDispose]() {
- await promisify(super.close).call(this);
+ await promisify(this.close).call(this);
}
}
diff --git a/test/parallel/test-http2-server-async-dispose.js b/test/parallel/test-http2-server-async-dispose.js
index 4782e12e417..fb7d458b31d 100644
--- a/test/parallel/test-http2-server-async-dispose.js
+++ b/test/parallel/test-http2-server-async-dispose.js
@@ -5,6 +5,7 @@ const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
+const assert = require('assert');
const http2 = require('http2');
const server = http2.createServer();
@@ -13,3 +14,17 @@ server.listen(0, common.mustCall(() => {
server.on('close', common.mustCall());
server[Symbol.asyncDispose]().then(common.mustCall());
}));
+
+// Disposing the server should close an idle session without client.close().
+const serverWithSession = http2.createServer();
+serverWithSession.listen(0, common.mustCall(() => {
+ const client = http2.connect(`http://localhost:${serverWithSession.address().port}`);
+ client.once('goaway', common.mustCall());
+ client.once('remoteSettings', common.mustCall(() => {
+ let serverClosed = false;
+ serverWithSession.once('close', () => { serverClosed = true; });
+ serverWithSession[Symbol.asyncDispose]().then(common.mustCall(() => {
+ assert.ok(serverClosed, 'asyncDispose resolved before the server closed');
+ }));
+ }));
+}));