-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src,http2: ensure cleanup if a frame is not sent
Call to JS and close the session if a frame is not sent even there is no frameError listener registered by user. PR-URL: #47244 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]>
- Loading branch information
1 parent
53d9eb5
commit a7620d1
Showing
2 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
test/parallel/test-h2-large-header-cause-client-to-hangup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
})); |