Skip to content

Commit 15879ad

Browse files
apapirovskiBridgeAR
authored andcommitted
test: expand http2 frameError test case
Expand maxSendHeaderBlockLength test to check what happens if frameError listener isn't available. PR-URL: #15298 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent 8589c70 commit 15879ad

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

test/parallel/test-http2-options-max-headers-block-length.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ server.listen(0);
1616
server.on('listening', common.mustCall(() => {
1717

1818
// Setting the maxSendHeaderBlockLength, then attempting to send a
19-
// headers block that is too big should cause a 'meError' to
19+
// headers block that is too big should cause a 'frameError' to
2020
// be emitted, and will cause the stream to be shutdown.
2121
const options = {
2222
maxSendHeaderBlockLength: 10
@@ -31,20 +31,45 @@ server.on('listening', common.mustCall(() => {
3131

3232
req.resume();
3333
req.on('end', common.mustCall(() => {
34-
server.close();
3534
client.destroy();
3635
}));
3736

3837
req.on('frameError', common.mustCall((type, code) => {
3938
assert.strictEqual(code, h2.constants.NGHTTP2_ERR_FRAME_SIZE_ERROR);
4039
}));
4140

42-
req.on('error', common.mustCall(common.expectsError({
41+
req.on('error', common.expectsError({
4342
code: 'ERR_HTTP2_STREAM_ERROR',
4443
type: Error,
4544
message: 'Stream closed with error code 7'
46-
})));
45+
}));
4746

4847
req.end();
4948

49+
// if no frameError listener, should emit 'error' with
50+
// code ERR_HTTP2_FRAME_ERROR
51+
const req2 = client.request({ ':path': '/' });
52+
53+
req2.on('response', common.mustNotCall());
54+
55+
req2.resume();
56+
req2.on('end', common.mustCall(() => {
57+
server.close();
58+
client.destroy();
59+
}));
60+
61+
req2.once('error', common.mustCall((err) => {
62+
common.expectsError({
63+
code: 'ERR_HTTP2_FRAME_ERROR',
64+
type: Error
65+
})(err);
66+
req2.on('error', common.expectsError({
67+
code: 'ERR_HTTP2_STREAM_ERROR',
68+
type: Error,
69+
message: 'Stream closed with error code 7'
70+
}));
71+
}));
72+
73+
req2.end();
74+
5075
}));

0 commit comments

Comments
 (0)