mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
06a43d4dca
Alternative to https://github.com/nodejs/node/pull/31590. It appears that the issue here is that the test falsely assumed that closing the client (which also currently destroys the socket rather than gracefully shutting down the connection) would still leave enough time for the server side to receive the stream error. Address that by explicitly waiting for the server side to receive the stream error before closing the client and the connection with it. Refs: https://github.com/nodejs/node/pull/31590 Refs: https://github.com/nodejs/node/issues/20750 PR-URL: https://github.com/nodejs/node/pull/31610 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
29 lines
669 B
JavaScript
29 lines
669 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
const http2 = require('http2');
|
|
|
|
let client;
|
|
let req;
|
|
const server = http2.createServer();
|
|
server.on('stream', common.mustCall((stream) => {
|
|
stream.on('error', common.mustCall(() => {
|
|
client.close();
|
|
stream.on('close', common.mustCall(() => {
|
|
server.close();
|
|
}));
|
|
}));
|
|
|
|
req.close(2);
|
|
}));
|
|
server.listen(0, common.mustCall(() => {
|
|
client = http2.connect(`http://localhost:${server.address().port}`);
|
|
req = client.request();
|
|
req.resume();
|
|
req.on('error', common.mustCall(() => {
|
|
req.on('close', common.mustCall());
|
|
}));
|
|
}));
|