Skip to content

Commit

Permalink
Increase max event listeners globally
Browse files Browse the repository at this point in the history
  • Loading branch information
mayfield committed Dec 13, 2024
1 parent 290ad17 commit 69e643a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/headless.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;

Expand Down Expand Up @@ -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"),
Expand Down
3 changes: 3 additions & 0 deletions src/main.mjs
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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');
Expand Down

0 comments on commit 69e643a

Please sign in to comment.