diff options
author | Rich Trott <rtrott@gmail.com> | 2023-02-21 04:46:21 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-21 12:46:21 +0000 |
commit | d1b29b4661cdce79aff5f288940806cabc13cb1f (patch) | |
tree | 3293991d0d9eed8f6f056c341d9f3f94b6978c52 /test/known_issues | |
parent | 254574e2fd8b268f3f957b3cfb7299a38971ca94 (diff) | |
download | node-new-d1b29b4661cdce79aff5f288940806cabc13cb1f.tar.gz |
Revert "src: let http2 streams end after session close"
This reverts commit dee882e94f4caa4e1cd608013f90f6a14629403f.
Moved the test that demonstrated what this commit was fixing to the
`known_issues` folder.
Fixes: https://github.com/nodejs/node/issues/46234
PR-URL: https://github.com/nodejs/node/pull/46721
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Diffstat (limited to 'test/known_issues')
-rw-r--r-- | test/known_issues/test-http2-trailers-after-session-close.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/known_issues/test-http2-trailers-after-session-close.js b/test/known_issues/test-http2-trailers-after-session-close.js new file mode 100644 index 0000000000..3d5be11e5b --- /dev/null +++ b/test/known_issues/test-http2-trailers-after-session-close.js @@ -0,0 +1,54 @@ +'use strict'; + +// Fixes: https://github.com/nodejs/node/issues/42713 +const common = require('../common'); +if (!common.hasCrypto) { + // Remove require('assert').fail when issue is fixed and test + // is moved out of the known_issues directory. + require('assert').fail('missing crypto'); + common.skip('missing crypto'); +} +const assert = require('assert'); +const http2 = require('http2'); + +const { + HTTP2_HEADER_PATH, + HTTP2_HEADER_STATUS, + HTTP2_HEADER_METHOD, +} = http2.constants; + +const server = http2.createServer(); +server.on('stream', common.mustCall((stream) => { + server.close(); + stream.session.close(); + stream.on('wantTrailers', common.mustCall(() => { + stream.sendTrailers({ xyz: 'abc' }); + })); + + stream.respond({ [HTTP2_HEADER_STATUS]: 200 }, { waitForTrailers: true }); + stream.write('some data'); + stream.end(); +})); + +server.listen(0, common.mustCall(() => { + const port = server.address().port; + const client = http2.connect(`http://localhost:${port}`); + client.socket.on('close', common.mustCall()); + const req = client.request({ + [HTTP2_HEADER_PATH]: '/', + [HTTP2_HEADER_METHOD]: 'POST', + }); + req.end(); + req.on('response', common.mustCall()); + let data = ''; + req.on('data', (chunk) => { + data += chunk; + }); + req.on('end', common.mustCall(() => { + assert.strictEqual(data, 'some data'); + })); + req.on('trailers', common.mustCall((headers) => { + assert.strictEqual(headers.xyz, 'abc'); + })); + req.on('close', common.mustCall()); +})); |