Commit fb0ee38162c for nodejs
commit fb0ee38162c32f65070c9a3bdd4d5e814dcc7a0b
Author: Yuya Inoue <65857152+inoway46@users.noreply.github.com>
Date: Sun Nov 29 21:36:38 2026 +0900
test: cover closed stream in http2 compat 1xx methods
Add the missing case for the closed-stream check that the 1xx methods
share through writeInformation().
Refs: https://github.com/nodejs/node/pull/67470
Refs: https://github.com/nodejs/node/pull/67728
Signed-off-by: inoway46 <inoueyuya416@gmail.com>
Assisted-by: Claude Code
PR-URL: https://github.com/nodejs/node/pull/67777
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
diff --git a/test/parallel/test-http2-compat-write-information-callback.js b/test/parallel/test-http2-compat-write-information-callback.js
index ecca7897ed2..2c26c35481f 100644
--- a/test/parallel/test-http2-compat-write-information-callback.js
+++ b/test/parallel/test-http2-compat-write-information-callback.js
@@ -142,3 +142,37 @@ const http2 = require('node:http2');
}));
}));
}
+
+// Nothing is sent, and the callback is not called, once the stream has
+// closed before the response headers were sent.
+{
+ const server = http2.createServer();
+
+ server.on('request', common.mustCall((req, res) => {
+ res.stream.on('close', common.mustCall(() => {
+ assert.strictEqual(res.stream.headersSent, false);
+ assert.strictEqual(res.writeContinue(common.mustNotCall()), false);
+ assert.strictEqual(res.writeProcessing(common.mustNotCall()), false);
+ assert.strictEqual(res.writeEarlyHints({
+ link: '</styles.css>; rel=preload; as=style',
+ }, common.mustNotCall()), false);
+ assert.strictEqual(
+ res.writeInformation(110, undefined, common.mustNotCall()), false);
+ }));
+ res.stream.close();
+ }));
+
+ server.listen(0, common.mustCall(() => {
+ const client = http2.connect(`http://localhost:${server.address().port}`);
+ const req = client.request();
+ req.on('headers', common.mustNotCall());
+ req.on('response', common.mustNotCall());
+ // The server reset the stream before sending END_STREAM.
+ req.on('error', common.expectsError({ code: 'ERR_HTTP2_STREAM_ABORTED' }));
+ req.resume();
+ req.on('close', common.mustCall(() => {
+ client.close();
+ server.close();
+ }));
+ }));
+}