node/test/parallel/test-http2-compat-errors.js
Tim Perry 5f9618049b
http2: error for incomplete reads on RST, auto-drain, deprecate aborted
Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63249
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-06-01 10:59:19 +00:00

39 lines
1 KiB
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const h2 = require('http2');
// Errors on the underlying stream surface on Http2ServerRequest
let expected = null;
const server = h2.createServer(common.mustCall(function(req, res) {
res.stream.on('error', common.mustCall((err) => {
assert.strictEqual(err, expected);
}));
req.on('error', common.mustCall((err) => {
assert.strictEqual(err, expected);
}));
res.on('error', common.mustNotCall());
req.on('aborted', common.mustCall());
res.on('aborted', common.mustNotCall());
res.write('hello');
expected = new Error('kaboom');
res.stream.destroy(expected);
server.close();
}));
server.listen(0, common.mustCall(function() {
const url = `http://localhost:${server.address().port}`;
const client = h2.connect(url, common.mustCall(() => {
const request = client.request();
request.on('data', common.mustCall((chunk) => {
client.destroy();
}));
}));
}));