-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http2: fix memory leak when nghttp2 hd threshold is reached
Refs: #45295 PR-URL: #41502 Backport-PR-URL: #45310 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Stephen Belanger <[email protected]>
- Loading branch information
1 parent
d6f1d71
commit c3a90c4
Showing
3 changed files
with
72 additions
and
0 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
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
46 changes: 46 additions & 0 deletions
46
test/parallel/test-http2-options-max-headers-exceeds-nghttp2.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,46 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
const h2 = require('http2'); | ||
|
||
const server = h2.createServer(); | ||
|
||
server.on('stream', common.mustNotCall()); | ||
server.on('error', common.mustNotCall()); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
|
||
// Setting the maxSendHeaderBlockLength > nghttp2 threshold | ||
// cause a 'sessionError' and no memory leak when session destroy | ||
const options = { | ||
maxSendHeaderBlockLength: 100000 | ||
}; | ||
|
||
const client = h2.connect(`http://localhost:${server.address().port}`, | ||
options); | ||
client.on('error', common.expectsError({ | ||
code: 'ERR_HTTP2_SESSION_ERROR', | ||
name: 'Error', | ||
message: 'Session closed with error code 9' | ||
})); | ||
|
||
const req = client.request({ | ||
// Greater than 65536 bytes | ||
'test-header': 'A'.repeat(90000) | ||
}); | ||
req.on('response', common.mustNotCall()); | ||
|
||
req.on('close', common.mustCall(() => { | ||
client.close(); | ||
server.close(); | ||
})); | ||
|
||
req.on('error', common.expectsError({ | ||
code: 'ERR_HTTP2_SESSION_ERROR', | ||
name: 'Error', | ||
message: 'Session closed with error code 9' | ||
})); | ||
req.end(); | ||
})); |