0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-http2-server-close-callback.js
Santiago Gimeno 5374e15d24
http2: improve session close/destroy procedures
Don't destroy the socket when closing the session but let it end
gracefully.
Also, when destroying the session, on Windows, we would get ECONNRESET
errors, make sure we take those into account in our tests.

PR-URL: https://github.com/nodejs/node/pull/45115
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2022-10-26 09:16:00 +00:00

28 lines
622 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const Countdown = require('../common/countdown');
const http2 = require('http2');
const server = http2.createServer();
let session;
const countdown = new Countdown(2, () => {
server.close(common.mustSucceed());
session.close();
});
server.listen(0, common.mustCall(() => {
const client = http2.connect(`http://localhost:${server.address().port}`);
client.on('connect', common.mustCall(() => countdown.dec()));
}));
server.on('session', common.mustCall((s) => {
session = s;
countdown.dec();
}));