-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
Closed
Description
Version
v23.7.0
Platform
Darwin Mac.lan 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:24 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6030 arm64
Subsystem
http2
What steps will reproduce the bug?
When an HTTP/2 connection is established between a client and server, and the client initiates a request, a specific issue occurs during connection termination. If the server attempts to close the HTTP/2 session immediately after responding to the request with an empty response (using response.end() with no data), the client fails to receive the expected GOAWAY frame and response header.
index.js:
'use strict';
const h2 = require('http2');
const server = h2.createServer();
let session;
server.on('session', function(s) {
session = s;
});
server.listen(0, function() {
const port = server.address().port;
const url = `http://localhost:${port}`;
const client = h2.connect(url, function() {
const headers = {
':path': '/',
':method': 'GET',
':scheme': 'http',
};
console.log('Client: Sending request');
const request = client.request(headers);
request.on('response', function(headers) {
console.log('Client: Received response headers:', headers);
});
request.on('end', function() {
client.close();
});
client.on('goaway', function(errorCode, lastStreamID, opaqueData) {
console.log(`Client: Received GOAWAY frame`, {
errorCode,
lastStreamID,
opaqueData: opaqueData ? opaqueData.toString() : undefined
});
});
request.end();
request.resume();
});
});
server.once('request', function(request, response) {
response.on('finish', function() {
session.close();
});
response.end();
});
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Expectation is that on graceful session close, client should receive a proper response and goaway frame.
For above code, the response should look like:
Client: Sending request
Client: Received response headers: [Object: null prototype] {
':status': 200,
date: 'Wed, 09 Apr 2025 19:47:05 GMT',
Symbol(sensitiveHeaders): []
}
Client: Received GOAWAY frame { errorCode: 0, lastStreamID: 1, opaqueData: undefined }
Client: Received GOAWAY frame { errorCode: 0, lastStreamID: 1, opaqueData: undefined }
(ignore the date value)
What do you see instead?
Instead I am seeing:
Client: Sending request
Additional information
No response
Metadata
Metadata
Assignees
Labels
No labels