From 8403f00dc3e8f1c3c5cae4c4aec2eb10733cc15c Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Thu, 8 Mar 2018 16:22:23 +0100 Subject: 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 --- test/parallel/test-http2-server-rst-stream.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'test/parallel/test-http2-server-rst-stream.js') 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); }); -- cgit v1.2.1