diff options
author | Myles Borins <mylesborins@google.com> | 2018-11-27 17:46:59 -0500 |
---|---|---|
committer | Beth Griggs <Bethany.Griggs@uk.ibm.com> | 2018-12-11 15:45:52 +0000 |
commit | 394cb42962f542127ab3e8309d3143319ab44226 (patch) | |
tree | 9e707982858d7e24cf2d917a00cdaeba22faec36 | |
parent | 62fb5dbec557745f9f828d728ca25f327ca5300c (diff) | |
download | node-new-394cb42962f542127ab3e8309d3143319ab44226.tar.gz |
test: verify order of error in h2 server stream
Currently the order of error / closing of an h2 stream is consistent
in 10.x, 11.x, and master. There appears to be an unexpected behavior
difference in 8.x. This test will be used to bisect the commit that will
fix this behavior change and ensure there are no future regressions.
PR-URL: https://github.com/nodejs/node/pull/24685
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
-rw-r--r-- | test/parallel/test-http2-error-order.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/parallel/test-http2-error-order.js b/test/parallel/test-http2-error-order.js new file mode 100644 index 0000000000..8bf0f03dba --- /dev/null +++ b/test/parallel/test-http2-error-order.js @@ -0,0 +1,43 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); + +const assert = require('assert'); +const { createServer, connect } = require('http2'); + +const messages = []; +const expected = [ + 'Stream:created', + 'Stream:error', + 'Stream:close', + 'Request:error' +]; + +const server = createServer(); + +server.on('stream', (stream) => { + messages.push('Stream:created'); + stream + .on('close', () => messages.push('Stream:close')) + .on('error', (err) => messages.push('Stream:error')) + .respondWithFile('dont exist'); +}); + +server.listen(0); + +const client = connect(`http://localhost:${server.address().port}`); +const req = client.request(); + +req.on('response', common.mustNotCall()); + +req.on('error', () => { + messages.push('Request:error'); + client.close(); +}); + +client.on('close', common.mustCall(() => { + assert.deepStrictEqual(messages, expected); + server.close(); +})); |