Skip to content
Draft
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
6 changes: 0 additions & 6 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const {
ObjectSetPrototypeOf,
ReflectApply,
Symbol,
SymbolAsyncDispose,
SymbolFor,
} = primordials;

Expand Down Expand Up @@ -82,7 +81,6 @@ const {
const {
assignFunctionName,
kEmptyObject,
promisify,
} = require('internal/util');
const {
validateInteger,
Expand Down Expand Up @@ -580,10 +578,6 @@ Server.prototype.close = function close() {
return this;
};

Server.prototype[SymbolAsyncDispose] = assignFunctionName(SymbolAsyncDispose, async function() {
await promisify(this.close).call(this);
});

Server.prototype.closeAllConnections = function closeAllConnections() {
if (!this[kConnections]) {
return;
Expand Down
6 changes: 0 additions & 6 deletions lib/https.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ const {
ObjectSetPrototypeOf,
ReflectApply,
ReflectConstruct,
SymbolAsyncDispose,
} = primordials;

const {
assertCrypto,
kEmptyObject,
promisify,
} = require('internal/util');
assertCrypto();

Expand Down Expand Up @@ -116,10 +114,6 @@ Server.prototype.close = function close() {
return this;
};

Server.prototype[SymbolAsyncDispose] = async function() {
await FunctionPrototypeCall(promisify(this.close), this);
};

/**
* Creates a new `https.Server` instance.
* @param {{
Expand Down
5 changes: 0 additions & 5 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const {
SafeMap,
SafeSet,
Symbol,
SymbolAsyncDispose,
SymbolDispose,
Uint32Array,
Uint8Array,
Expand Down Expand Up @@ -3346,10 +3345,6 @@ class Http2Server extends NETServer {
ReflectApply(NETServer.prototype.close, this, arguments);
closeAllSessions(this);
}

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

Http2Server.prototype[EventEmitter.captureRejectionSymbol] = function(
Expand Down
5 changes: 3 additions & 2 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const {
const { isUint8Array } = require('internal/util/types');
const { queueMicrotask } = require('internal/process/task_queues');
const {
assignFunctionName,
guessHandleType,
isWindows,
kEmptyObject,
Expand Down Expand Up @@ -2391,12 +2392,12 @@ Server.prototype.close = function(cb) {
return this;
};

Server.prototype[SymbolAsyncDispose] = async function() {
Server.prototype[SymbolAsyncDispose] = assignFunctionName(SymbolAsyncDispose, async function() {
if (!this._handle) {
return;
}
await FunctionPrototypeCall(promisify(this.close), this);
};
});

Server.prototype._emitCloseIfDrained = function() {
debug('SERVER _emitCloseIfDrained');
Expand Down
4 changes: 4 additions & 0 deletions test/parallel/test-http-server-async-dispose.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ const { kConnectionsCheckingInterval } = require('_http_server');
const server = createServer();

server.listen(0, common.mustCall(() => {
assert.strictEqual(server[Symbol.asyncDispose].name, '[Symbol.asyncDispose]');
server.on('close', common.mustCall());
server[Symbol.asyncDispose]().then(common.mustCall(() => {
assert(server[kConnectionsCheckingInterval]._destroyed);

// Disposer must be idempotent, subsequent call must not throw
server[Symbol.asyncDispose]().then(common.mustCall());
}));
}));
9 changes: 8 additions & 1 deletion test/parallel/test-http2-server-async-dispose.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ if (!common.hasCrypto)
common.skip('missing crypto');

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

const server = http2.createServer();

server.listen(0, common.mustCall(() => {
assert.strictEqual(server[Symbol.asyncDispose].name, '[Symbol.asyncDispose]');
server.on('close', common.mustCall());
server[Symbol.asyncDispose]().then(common.mustCall());
server[Symbol.asyncDispose]().then(common.mustCall(() => {
assert.strictEqual(server._handle, null);

// Disposer must be idempotent, subsequent call must not throw
server[Symbol.asyncDispose]().then(common.mustCall());
}));
}));
4 changes: 4 additions & 0 deletions test/parallel/test-https-server-async-dispose.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ const { kConnectionsCheckingInterval } = require('_http_server');
const server = createServer();

server.listen(0, common.mustCall(() => {
assert.strictEqual(server[Symbol.asyncDispose].name, '[Symbol.asyncDispose]');
server.on('close', common.mustCall());
server[Symbol.asyncDispose]().then(common.mustCall(() => {
assert(server[kConnectionsCheckingInterval]._destroyed);

// Disposer must be idempotent, subsequent call must not throw
server[Symbol.asyncDispose]().then(common.mustCall());
}));
}));
Loading