@socketsecurity/registry
Advanced tools
Comparing version
@@ -8,7 +8,2 @@ 'use strict' | ||
const { envAsBoolean, envAsString } = require('./env') | ||
const abortController = new AbortController() | ||
const { signal: abortSignal } = abortController | ||
let _browserList | ||
@@ -138,2 +133,28 @@ function getBrowserList() { | ||
const abortController = new AbortController() | ||
const { signal: abortSignal } = abortController | ||
;(() => { | ||
// By manually setting `kMaxEventTargetListeners` on `abortSignal` we avoid: | ||
// TypeError [ERR_INVALID_ARG_TYPE]: The "emitter" argument must be an | ||
// instance of EventEmitter or EventTarget. Received an instance of | ||
// AbortSignal | ||
// | ||
// in some patch releases of Node 18-23 when calling events.getMaxListeners(abortSignal). | ||
// See https://github.com/nodejs/node/pull/56807. | ||
// | ||
// Instead of calling events.setMaxListeners(10, abortSignal) we set the symbol | ||
// property directly to keep the constants initialization platform agnostic and | ||
// not rely on the Node specific 'node:events' module up front. | ||
const symbols = Object.getOwnPropertySymbols(abortSignal) | ||
const kMaxEventTargetListeners = symbols.find( | ||
s => s.description === 'events.maxEventTargetListeners' | ||
) | ||
if (kMaxEventTargetListeners) { | ||
// The default events.defaultMaxListeners value is 10. | ||
// https://nodejs.org/api/events.html#eventsdefaultmaxlisteners | ||
abortSignal[kMaxEventTargetListeners] = 10 | ||
} | ||
})() | ||
// Detect ^C, i.e. Ctrl + C. | ||
@@ -436,2 +457,4 @@ signalExit.onExit(() => { | ||
const LAZY_ENV = () => { | ||
// Lazily require('./env'). | ||
const { envAsBoolean, envAsString } = require('./env') | ||
const { env } = getProcess() | ||
@@ -732,3 +755,3 @@ return Object.freeze({ | ||
const lazySpinner = () => | ||
// Lazily access require('./spinner').Spinner to avoid cyclical imports. | ||
// Lazily require('./spinner').Spinner to avoid cyclical imports. | ||
require('./spinner').Spinner() | ||
@@ -735,0 +758,0 @@ |
@@ -20,7 +20,6 @@ 'use strict' | ||
const { constructor: YoctoCtor } = yoctoFactory() | ||
// Lazily access require('./constants') to avoid cyclical imports. | ||
// Lazily require('./constants') and require('./logger') to avoid cyclical imports. | ||
const constants = require('./constants') | ||
const { logger } = require('./logger') | ||
const { abortSignal } = constants | ||
// Lazily access require('./logger') to avoid a future cyclical import. | ||
const { logger } = require('./logger') | ||
@@ -27,0 +26,0 @@ _Spinner = class Spinner extends YoctoCtor { |
{ | ||
"name": "@socketsecurity/registry", | ||
"version": "1.0.112", | ||
"version": "1.0.113", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Socket.dev registry helpers methods and metadata", |
168259
0.59%5566
0.4%