mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
net: server add asyncDispose
PR-URL: https://github.com/nodejs/node/pull/48717 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
parent
17f6b8c49c
commit
0e9138d173
3 changed files with 51 additions and 1 deletions
11
lib/net.js
11
lib/net.js
|
@ -28,6 +28,7 @@ const {
|
|||
ArrayPrototypePush,
|
||||
Boolean,
|
||||
FunctionPrototypeBind,
|
||||
FunctionPrototypeCall,
|
||||
MathMax,
|
||||
Number,
|
||||
NumberIsNaN,
|
||||
|
@ -35,6 +36,7 @@ const {
|
|||
ObjectDefineProperty,
|
||||
ObjectSetPrototypeOf,
|
||||
Symbol,
|
||||
SymbolAsyncDispose,
|
||||
SymbolDispose,
|
||||
} = primordials;
|
||||
|
||||
|
@ -112,7 +114,7 @@ const {
|
|||
} = require('internal/errors');
|
||||
const { isUint8Array } = require('internal/util/types');
|
||||
const { queueMicrotask } = require('internal/process/task_queues');
|
||||
const { kEmptyObject, guessHandleType } = require('internal/util');
|
||||
const { kEmptyObject, guessHandleType, promisify } = require('internal/util');
|
||||
const {
|
||||
validateAbortSignal,
|
||||
validateBoolean,
|
||||
|
@ -2243,6 +2245,13 @@ Server.prototype.close = function(cb) {
|
|||
return this;
|
||||
};
|
||||
|
||||
Server.prototype[SymbolAsyncDispose] = async function() {
|
||||
if (!this._handle) {
|
||||
return;
|
||||
}
|
||||
return FunctionPrototypeCall(promisify(this.close), this);
|
||||
};
|
||||
|
||||
Server.prototype._emitCloseIfDrained = function() {
|
||||
debug('SERVER _emitCloseIfDrained');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue