From 69e643ab84780c1ed65a431ef0bf614878c40adb Mon Sep 17 00:00:00 2001 From: Justin Mayfield Date: Fri, 13 Dec 2024 14:13:56 -0700 Subject: [PATCH] Increase max event listeners globally --- src/headless.mjs | 5 +++-- src/main.mjs | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/headless.mjs b/src/headless.mjs index 154548db..9efb53cb 100644 --- a/src/headless.mjs +++ b/src/headless.mjs @@ -2,7 +2,7 @@ import process from 'node:process'; import os from 'node:os'; import path from 'node:path'; import childProcess from 'node:child_process'; -import {EventEmitter} from 'node:events'; +import events from 'node:events'; import fs from './fs-safe.js'; import * as storage from './storage.mjs'; import * as rpc from './rpc.mjs'; @@ -13,6 +13,7 @@ import * as app from './app.mjs'; import * as logging from './logging.js'; Error.stackTraceLimit = 25; +events.defaultMaxListeners = 100; const isDEV = true; @@ -133,7 +134,7 @@ async function main() { const sauceApp = new NodeSauceApp({appPath}); sauceApp.rpcEventEmitters.set('logs', logEmitter); sauceApp.rpcEventEmitters.set('mods', mods.eventEmitter); - sauceApp.rpcEventEmitters.set('windows', new EventEmitter()); + sauceApp.rpcEventEmitters.set('windows', new events.EventEmitter()); rpc.register(() => logQueue, {name: 'getLogs'}); rpc.register(() => logQueue.length = 0, {name: 'clearLogs'}); rpc.register(() => () => console.warn("File logging disabled for headless mode"), diff --git a/src/main.mjs b/src/main.mjs index 26394853..093c0131 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -1,4 +1,5 @@ import path from 'node:path'; +import events from 'node:events'; import * as report from '../shared/report.mjs'; import * as storage from './storage.mjs'; import * as menu from './menu.mjs'; @@ -11,6 +12,8 @@ import * as mods from './mods.mjs'; import {parseArgs} from './argparse.mjs'; import * as app from './app.mjs'; +events.defaultMaxListeners = 100; + const sauceScheme = 'sauce4zwift'; const require = createRequire(import.meta.url); const pkg = require('../package.json');