0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 13:09:21 +01:00

lib: remove Symbol[Async]Dispose polyfills

PR-URL: https://github.com/nodejs/node/pull/55276
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
This commit is contained in:
Michaël Zasso 2024-10-07 11:47:44 +02:00 committed by GitHub
parent 9a9409ff1f
commit d5eb9a378e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 33 additions and 70 deletions

View File

@ -29,6 +29,7 @@ const {
ObjectSetPrototypeOf,
ReflectApply,
Symbol,
SymbolAsyncDispose,
SymbolFor,
} = primordials;
@ -81,7 +82,6 @@ const {
const {
kEmptyObject,
promisify,
SymbolAsyncDispose,
} = require('internal/util');
const {
validateInteger,

View File

@ -42,6 +42,7 @@ const {
StringPrototypeIncludes,
StringPrototypeSlice,
StringPrototypeToUpperCase,
SymbolDispose,
} = primordials;
const {
@ -50,7 +51,6 @@ const {
getSystemErrorName,
kEmptyObject,
promisify,
SymbolDispose,
} = require('internal/util');
const { isArrayBufferView } = require('internal/util/types');
let debug = require('internal/util/debuglog').debuglog(

View File

@ -30,6 +30,8 @@ const {
ObjectDefineProperty,
ObjectSetPrototypeOf,
ReflectApply,
SymbolAsyncDispose,
SymbolDispose,
} = primordials;
const {
@ -61,7 +63,7 @@ const {
validatePort,
} = require('internal/validators');
const { Buffer } = require('buffer');
const { deprecate, guessHandleType, promisify, SymbolAsyncDispose, SymbolDispose } = require('internal/util');
const { deprecate, guessHandleType, promisify } = require('internal/util');
const { isArrayBufferView } = require('internal/util/types');
const EventEmitter = require('events');
const { addAbortListener } = require('internal/events/abort_listener');

View File

@ -47,11 +47,12 @@ const {
StringPrototypeSplit,
Symbol,
SymbolAsyncIterator,
SymbolDispose,
SymbolFor,
} = primordials;
const kRejection = SymbolFor('nodejs.rejection');
const { SymbolDispose, kEmptyObject, spliceOne } = require('internal/util');
const { kEmptyObject, spliceOne } = require('internal/util');
const {
inspect,

View File

@ -33,13 +33,13 @@ const {
ObjectSetPrototypeOf,
ReflectApply,
ReflectConstruct,
SymbolAsyncDispose,
} = primordials;
const {
assertCrypto,
kEmptyObject,
promisify,
SymbolAsyncDispose,
} = require('internal/util');
assertCrypto();

View File

@ -4,11 +4,8 @@ const {
JSONParse,
JSONStringify,
SafeMap,
} = primordials;
const {
SymbolDispose,
} = require('internal/util');
} = primordials;
const {
ERR_INSPECTOR_ALREADY_ACTIVATED,

View File

@ -12,6 +12,7 @@ const {
ReflectApply,
StringPrototypeSlice,
Symbol,
SymbolDispose,
Uint8Array,
} = primordials;
@ -55,7 +56,7 @@ const { TTY } = internalBinding('tty_wrap');
const { UDP } = internalBinding('udp_wrap');
const SocketList = require('internal/socket_list');
const { owner_symbol } = require('internal/async_hooks').symbols;
const { convertToValidSignal, deprecate, SymbolDispose } = require('internal/util');
const { convertToValidSignal, deprecate } = require('internal/util');
const { isArrayBufferView } = require('internal/util/types');
const spawn_sync = internalBinding('spawn_sync');
const { kStateSymbol } = require('internal/dgram');

View File

@ -2,7 +2,7 @@
const {
SymbolDispose,
} = require('internal/util');
} = primordials;
const {
validateAbortSignal,
validateFunction,

View File

@ -15,6 +15,7 @@ const {
SafeArrayIterator,
SafePromisePrototypeFinally,
Symbol,
SymbolAsyncDispose,
Uint8Array,
uncurryThis,
} = primordials;
@ -99,7 +100,6 @@ const {
promisify,
isWindows,
isMacOS,
SymbolAsyncDispose,
} = require('internal/util');
const EventEmitter = require('events');
const { StringDecoder } = require('string_decoder');

View File

@ -19,6 +19,8 @@ const {
SafeMap,
SafeSet,
Symbol,
SymbolAsyncDispose,
SymbolDispose,
Uint32Array,
Uint8Array,
} = primordials;
@ -28,8 +30,6 @@ const {
customInspectSymbol: kInspect,
kEmptyObject,
promisify,
SymbolAsyncDispose,
SymbolDispose,
} = require('internal/util');
assertCrypto();

View File

@ -14,7 +14,6 @@ const {
ObjectFreeze,
String,
StringPrototypeStartsWith,
Symbol,
globalThis,
} = primordials;
@ -29,8 +28,6 @@ const {
defineReplaceableLazyAttribute,
setupCoverageHooks,
emitExperimentalWarning,
SymbolAsyncDispose,
SymbolDispose,
deprecate,
} = require('internal/util');
@ -121,8 +118,6 @@ function prepareExecution(options) {
require('internal/dns/utils').initializeDns();
setupSymbolDisposePolyfill();
if (isMainThread) {
assert(internalBinding('worker').isMainThread);
// Worker threads will get the manifest in the message handler.
@ -157,31 +152,6 @@ function prepareExecution(options) {
return mainEntry;
}
function setupSymbolDisposePolyfill() {
// TODO(MoLow): Remove this polyfill once Symbol.dispose and Symbol.asyncDispose are available in V8.
// eslint-disable-next-line node-core/prefer-primordials
if (typeof Symbol.dispose !== 'symbol') {
ObjectDefineProperty(Symbol, 'dispose', {
__proto__: null,
configurable: false,
enumerable: false,
value: SymbolDispose,
writable: false,
});
}
// eslint-disable-next-line node-core/prefer-primordials
if (typeof Symbol.asyncDispose !== 'symbol') {
ObjectDefineProperty(Symbol, 'asyncDispose', {
__proto__: null,
configurable: false,
enumerable: false,
value: SymbolAsyncDispose,
writable: false,
});
}
}
function setupUserModules(forceDefaultLoader = false) {
initializeCJSLoader();
initializeESMLoader(forceDefaultLoader);

View File

@ -30,6 +30,7 @@ const {
StringPrototypeTrim,
Symbol,
SymbolAsyncIterator,
SymbolDispose,
} = primordials;
const { codes: {
@ -44,7 +45,7 @@ const {
validateString,
validateUint32,
} = require('internal/validators');
const { SymbolDispose, kEmptyObject } = require('internal/util');
const { kEmptyObject } = require('internal/util');
const {
inspect,
getStringWidth,

View File

@ -2,7 +2,7 @@
const {
SymbolDispose,
} = require('internal/util');
} = primordials;
const {
AbortError,

View File

@ -6,6 +6,7 @@
const {
Promise,
PromisePrototypeThen,
SymbolDispose,
} = primordials;
const {
@ -18,7 +19,6 @@ const {
const {
kEmptyObject,
once,
SymbolDispose,
} = require('internal/util');
const {
validateAbortSignal,

View File

@ -7,10 +7,11 @@ const {
ArrayIsArray,
Promise,
SymbolAsyncIterator,
SymbolDispose,
} = primordials;
const eos = require('internal/streams/end-of-stream');
const { SymbolDispose, once } = require('internal/util');
const { once } = require('internal/util');
const destroyImpl = require('internal/streams/destroy');
const Duplex = require('internal/streams/duplex');
const {

View File

@ -32,6 +32,7 @@ const {
Promise,
SafeSet,
Symbol,
SymbolAsyncDispose,
SymbolAsyncIterator,
SymbolSpecies,
TypedArrayPrototypeSet,
@ -43,9 +44,6 @@ Readable.ReadableState = ReadableState;
const EE = require('events');
const { Stream, prependListener } = require('internal/streams/legacy');
const { Buffer } = require('buffer');
const {
SymbolAsyncDispose,
} = require('internal/util');
const {
addAbortSignal,

View File

@ -35,6 +35,7 @@ const {
Promise,
StringPrototypeToLowerCase,
Symbol,
SymbolAsyncDispose,
SymbolHasInstance,
} = primordials;
@ -46,9 +47,6 @@ const Stream = require('internal/streams/legacy').Stream;
const { Buffer } = require('buffer');
const destroyImpl = require('internal/streams/destroy');
const eos = require('internal/streams/end-of-stream');
const {
SymbolAsyncDispose,
} = require('internal/util');
const {
addAbortSignal,

View File

@ -17,6 +17,7 @@ const {
Promise,
Symbol,
SymbolAsyncIterator,
SymbolDispose,
globalThis,
} = primordials;
@ -28,7 +29,6 @@ const {
const {
emitExperimentalWarning,
SymbolDispose,
} = require('internal/util');
const {
AbortError,

View File

@ -29,6 +29,7 @@ const {
StringPrototypeStartsWith,
StringPrototypeTrim,
Symbol,
SymbolDispose,
} = primordials;
const { getCallerLocation } = internalBinding('util');
const { exitCodes: { kGenericUserError } } = internalBinding('errors');
@ -55,7 +56,6 @@ const {
createDeferredPromise,
kEmptyObject,
once: runOnce,
SymbolDispose,
} = require('internal/util');
const { isPromise } = require('internal/util/types');
const {

View File

@ -932,14 +932,6 @@ module.exports = {
setupCoverageHooks,
removeColors,
// Define Symbol.dispose and Symbol.asyncDispose
// Until these are defined by the environment.
// TODO(MoLow): Remove this polyfill once Symbol.dispose and Symbol.asyncDispose are available in primordials.
// eslint-disable-next-line node-core/prefer-primordials
SymbolDispose: Symbol.dispose || SymbolFor('nodejs.dispose'),
// eslint-disable-next-line node-core/prefer-primordials
SymbolAsyncDispose: Symbol.asyncDispose || SymbolFor('nodejs.asyncDispose'),
// Symbol used to customize promisify conversion
customPromisifyArgs: kCustomPromisifyArgsSymbol,

View File

@ -22,6 +22,7 @@ const {
SafePromiseAll,
Symbol,
SymbolAsyncIterator,
SymbolDispose,
SymbolToStringTag,
TypedArrayPrototypeGetLength,
Uint8Array,
@ -54,7 +55,6 @@ const {
kEmptyObject,
kEnumerableProperty,
SideEffectFreeRegExpPrototypeSymbolReplace,
SymbolDispose,
} = require('internal/util');
const {

View File

@ -36,6 +36,8 @@ const {
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
SymbolAsyncDispose,
SymbolDispose,
} = primordials;
const EventEmitter = require('events');
@ -119,8 +121,6 @@ const {
isWindows,
kEmptyObject,
promisify,
SymbolAsyncDispose,
SymbolDispose,
} = require('internal/util');
const {
validateAbortSignal,

View File

@ -30,6 +30,7 @@ const {
Promise,
PromiseReject,
StringPrototypeSlice,
SymbolDispose,
} = primordials;
const {
@ -50,7 +51,6 @@ const {
const {
kEmptyObject,
promisify,
SymbolDispose,
} = require('internal/util');
const { validateAbortSignal } = require('internal/validators');

View File

@ -2,6 +2,7 @@
const {
Promise,
SymbolDispose,
} = primordials;
const {
@ -21,7 +22,6 @@ const { validateAbortSignal } = require('internal/validators');
const {
kEmptyObject,
SymbolDispose,
} = require('internal/util');
let addAbortListener;

View File

@ -26,6 +26,7 @@ const {
MathTrunc,
ObjectDefineProperties,
ObjectDefineProperty,
SymbolDispose,
SymbolToPrimitive,
} = primordials;
@ -57,7 +58,6 @@ const {
const {
promisify: { custom: customPromisify },
deprecate,
SymbolDispose,
} = require('internal/util');
let debug = require('internal/util/debuglog').debuglog('timer', (fn) => {
debug = fn;

View File

@ -431,7 +431,9 @@ declare namespace primordials {
export const SymbolPrototype: typeof Symbol.prototype
export const SymbolFor: typeof Symbol.for
export const SymbolKeyFor: typeof Symbol.keyFor
export const SymbolAsyncDispose: typeof Symbol.asyncDispose
export const SymbolAsyncIterator: typeof Symbol.asyncIterator
export const SymbolDispose: typeof Symbol.dispose
export const SymbolHasInstance: typeof Symbol.hasInstance
export const SymbolIsConcatSpreadable: typeof Symbol.isConcatSpreadable
export const SymbolIterator: typeof Symbol.iterator