-
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.
http2: close stream and session on frameError
PR-URL: #42147 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
- Loading branch information
Showing
4 changed files
with
77 additions
and
3 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
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,51 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const assert = require('assert'); | ||
const { createServer, constants, connect } = require('http2'); | ||
|
||
const server = createServer(); | ||
|
||
server.on('stream', (stream, headers) => { | ||
stream.respond(undefined, { waitForTrailers: true }); | ||
|
||
stream.on('data', common.mustNotCall()); | ||
|
||
stream.on('wantTrailers', common.mustCall(() => { | ||
// Trigger a frame error by sending a trailer that is too large | ||
stream.sendTrailers({ 'test-trailer': 'X'.repeat(64 * 1024) }); | ||
})); | ||
|
||
stream.on('frameError', common.mustCall((frameType, errorCode) => { | ||
assert.strictEqual(errorCode, constants.NGHTTP2_FRAME_SIZE_ERROR); | ||
})); | ||
|
||
stream.on('error', common.expectsError({ | ||
code: 'ERR_HTTP2_STREAM_ERROR', | ||
})); | ||
|
||
stream.on('close', common.mustCall()); | ||
|
||
stream.end(); | ||
}); | ||
|
||
server.listen(0, () => { | ||
const clientSession = connect(`http://localhost:${server.address().port}`); | ||
|
||
clientSession.on('frameError', common.mustNotCall()); | ||
clientSession.on('close', common.mustCall(() => { | ||
server.close(); | ||
})); | ||
|
||
const clientStream = clientSession.request(); | ||
|
||
clientStream.on('close', common.mustCall()); | ||
// These events mustn't be called once the frame size error is from the server | ||
clientStream.on('frameError', common.mustNotCall()); | ||
clientStream.on('error', common.mustNotCall()); | ||
|
||
clientStream.end(); | ||
}); |
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