Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3916,7 +3916,7 @@ class Http2Server extends NETServer {
}

async [SymbolAsyncDispose]() {
await promisify(super.close).call(this);
await promisify(this.close).call(this);
}
}

Expand Down
15 changes: 15 additions & 0 deletions test/parallel/test-http2-server-async-dispose.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');
const http2 = require('http2');

const server = http2.createServer();
Expand All @@ -13,3 +14,17 @@ server.listen(0, common.mustCall(() => {
server.on('close', common.mustCall());
server[Symbol.asyncDispose]().then(common.mustCall());
}));

// Disposing the server should close an idle session without client.close().
const serverWithSession = http2.createServer();
serverWithSession.listen(0, common.mustCall(() => {
const client = http2.connect(`http://localhost:${serverWithSession.address().port}`);
client.once('goaway', common.mustCall());
client.once('remoteSettings', common.mustCall(() => {
let serverClosed = false;
serverWithSession.once('close', () => { serverClosed = true; });
serverWithSession[Symbol.asyncDispose]().then(common.mustCall(() => {
assert.ok(serverClosed, 'asyncDispose resolved before the server closed');
}));
}));
}));
Loading