test: fix http2 connection abort test
Refs: https://github.com/nodejs/node/issues/21836 Refs: https://github.com/nodejs/node/pull/21561 PR-URL: https://github.com/nodejs/node/pull/21861 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
This commit is contained in:
parent
3095eecc47
commit
daa15b54ba
@ -3,6 +3,7 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
if (!common.hasCrypto)
|
if (!common.hasCrypto)
|
||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
const assert = require('assert');
|
||||||
const http2 = require('http2');
|
const http2 = require('http2');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ const {
|
|||||||
|
|
||||||
const server = http2.createServer();
|
const server = http2.createServer();
|
||||||
server.on('stream', common.mustCall((stream) => {
|
server.on('stream', common.mustCall((stream) => {
|
||||||
|
stream.on('error', (err) => assert.strictEqual(err.code, 'ECONNRESET'));
|
||||||
stream.respondWithFile(process.execPath, {
|
stream.respondWithFile(process.execPath, {
|
||||||
[HTTP2_HEADER_CONTENT_TYPE]: 'application/octet-stream'
|
[HTTP2_HEADER_CONTENT_TYPE]: 'application/octet-stream'
|
||||||
});
|
});
|
||||||
@ -22,16 +24,9 @@ server.listen(0, common.mustCall(() => {
|
|||||||
const req = client.request();
|
const req = client.request();
|
||||||
|
|
||||||
req.on('response', common.mustCall(() => {}));
|
req.on('response', common.mustCall(() => {}));
|
||||||
req.on('data', common.mustCall(() => {
|
req.on('data', common.mustCallAtLeast(() => {
|
||||||
net.Socket.prototype.destroy.call(client.socket);
|
net.Socket.prototype.destroy.call(client.socket);
|
||||||
server.close();
|
server.close();
|
||||||
}));
|
}));
|
||||||
req.end();
|
req.end();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// TODO(addaleax): This is a *hack*. HTTP/2 needs to have a proper way of
|
|
||||||
// dealing with this kind of issue.
|
|
||||||
process.once('uncaughtException', (err) => {
|
|
||||||
if (err.code === 'ECONNRESET') return;
|
|
||||||
throw err;
|
|
||||||
});
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user