Skip to content

Commit eea199b

Browse files
addaleaxtargos
authored andcommitted
test: fix http2 connection abort test
Refs: #21836 Refs: #21561 PR-URL: #21861 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Minwoo Jung <[email protected]>
1 parent e8d5787 commit eea199b

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

test/parallel/test-http2-respond-with-file-connection-abort.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const common = require('../common');
44
if (!common.hasCrypto)
55
common.skip('missing crypto');
6+
const assert = require('assert');
67
const http2 = require('http2');
78
const net = require('net');
89

@@ -12,6 +13,7 @@ const {
1213

1314
const server = http2.createServer();
1415
server.on('stream', common.mustCall((stream) => {
16+
stream.on('error', (err) => assert.strictEqual(err.code, 'ECONNRESET'));
1517
stream.respondWithFile(process.execPath, {
1618
[HTTP2_HEADER_CONTENT_TYPE]: 'application/octet-stream'
1719
});
@@ -22,16 +24,9 @@ server.listen(0, common.mustCall(() => {
2224
const req = client.request();
2325

2426
req.on('response', common.mustCall(() => {}));
25-
req.on('data', common.mustCall(() => {
27+
req.on('data', common.mustCallAtLeast(() => {
2628
net.Socket.prototype.destroy.call(client.socket);
2729
server.close();
2830
}));
2931
req.end();
3032
}));
31-
32-
// TODO(addaleax): This is a *hack*. HTTP/2 needs to have a proper way of
33-
// dealing with this kind of issue.
34-
process.once('uncaughtException', (err) => {
35-
if (err.code === 'ECONNRESET') return;
36-
throw err;
37-
});

0 commit comments

Comments
 (0)