summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-server-rst-stream.js
diff options
context:
space:
mode:
authorMatteo Collina <hello@matteocollina.com>2018-03-08 16:22:23 +0100
committerMatteo Collina <hello@matteocollina.com>2018-03-12 09:36:31 +0100
commit8403f00dc3e8f1c3c5cae4c4aec2eb10733cc15c (patch)
treed210f89a620653e6c1ab7e7026dbb840a1e411d3 /test/parallel/test-http2-server-rst-stream.js
parent33e63fe64f238227481b83fc401a1a2371013995 (diff)
downloadnode-new-8403f00dc3e8f1c3c5cae4c4aec2eb10733cc15c.tar.gz
http2: fixes error handling
There should be no default error handling when using Http2Stream. All errors will end up in `'streamError'` on the server anyway, but they are emitted on `'stream'` as well, otherwise some error conditions are impossible to debug. See: https://github.com/nodejs/node/pull/14991 PR-URL: https://github.com/nodejs/node/pull/19232 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-http2-server-rst-stream.js')
-rw-r--r--test/parallel/test-http2-server-rst-stream.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/test/parallel/test-http2-server-rst-stream.js b/test/parallel/test-http2-server-rst-stream.js
index d19704509a..402ff07fa9 100644
--- a/test/parallel/test-http2-server-rst-stream.js
+++ b/test/parallel/test-http2-server-rst-stream.js
@@ -18,14 +18,22 @@ const {
const tests = [
[NGHTTP2_NO_ERROR, false],
[NGHTTP2_NO_ERROR, false],
- [NGHTTP2_PROTOCOL_ERROR, true],
+ [NGHTTP2_PROTOCOL_ERROR, true, 'NGHTTP2_PROTOCOL_ERROR'],
[NGHTTP2_CANCEL, false],
- [NGHTTP2_REFUSED_STREAM, true],
- [NGHTTP2_INTERNAL_ERROR, true]
+ [NGHTTP2_REFUSED_STREAM, true, 'NGHTTP2_REFUSED_STREAM'],
+ [NGHTTP2_INTERNAL_ERROR, true, 'NGHTTP2_INTERNAL_ERROR']
];
const server = http2.createServer();
server.on('stream', (stream, headers) => {
+ const test = tests.find((t) => t[0] === Number(headers.rstcode));
+ if (test[1]) {
+ stream.on('error', common.expectsError({
+ type: Error,
+ code: 'ERR_HTTP2_STREAM_ERROR',
+ message: `Stream closed with error code ${test[2]}`
+ }));
+ }
stream.close(headers.rstcode | 0);
});