diff --git a/src/node_http2.cc b/src/node_http2.cc index 7e8e04f440ae85..26345c429630bf 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -1072,8 +1072,7 @@ int Http2Session::OnFrameNotSent(nghttp2_session* handle, // Do not report if the frame was not sent due to the session closing if (error_code == NGHTTP2_ERR_SESSION_CLOSING || error_code == NGHTTP2_ERR_STREAM_CLOSED || - error_code == NGHTTP2_ERR_STREAM_CLOSING || - session->js_fields_->frame_error_listener_count == 0) { + error_code == NGHTTP2_ERR_STREAM_CLOSING) { // Nghttp2 contains header limit of 65536. When this value is exceeded the // pipeline is stopped and we should remove the current headers reference // to destroy the session completely. diff --git a/test/parallel/test-h2-large-header-cause-client-to-hangup.js b/test/parallel/test-h2-large-header-cause-client-to-hangup.js new file mode 100644 index 00000000000000..b8b08cecf6817c --- /dev/null +++ b/test/parallel/test-h2-large-header-cause-client-to-hangup.js @@ -0,0 +1,38 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); +const http2 = require('http2'); +const assert = require('assert'); +const { + DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE, + NGHTTP2_CANCEL, +} = http2.constants; + +const headerSize = DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE; +const timeout = common.platformTimeout(2_000); +const timer = setTimeout(() => assert.fail(`http2 client timedout +when server can not manage to send a header of size ${headerSize}`), timeout); + +const server = http2.createServer((req, res) => { + res.setHeader('foobar', 'a'.repeat(DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE)); + res.end(); +}); + +server.listen(0, common.mustCall(() => { + const clientSession = http2.connect(`http://localhost:${server.address().port}`); + clientSession.on('close', common.mustCall()); + clientSession.on('remoteSettings', send); + + function send() { + const stream = clientSession.request({ ':path': '/' }); + stream.on('close', common.mustCall(() => { + assert.strictEqual(stream.rstCode, NGHTTP2_CANCEL); + clearTimeout(timer); + server.close(); + })); + + stream.end(); + } +}));