fix test errors about event emitter

This commit is contained in:
Hazelnoot 2025-10-08 20:51:49 -04:00
parent 5478dcce41
commit 14db6444b1
9 changed files with 168 additions and 11 deletions

View file

@ -13,6 +13,7 @@ import { inspect } from 'node:util';
import chalk from 'chalk';
import Xev from 'xev';
import Logger from '@/logger.js';
import { prepEnv } from '@/boot/prepEnv.js';
import { envOption } from '../env.js';
import { masterMain } from './master.js';
import { workerMain } from './worker.js';
@ -22,8 +23,7 @@ import 'reflect-metadata';
process.title = `Misskey (${cluster.isPrimary ? 'master' : 'worker'})`;
Error.stackTraceLimit = Infinity;
EventEmitter.defaultMaxListeners = 128;
prepEnv();
const logger = new Logger('core', 'cyan');
const clusterLogger = logger.createSubLogger('cluster', 'orange');

View file

@ -0,0 +1,19 @@
/*
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { EventEmitter } from 'node:events';
/**
* Configures Node.JS global runtime options for values appropriate for Sharkey.
*/
export function prepEnv() {
// Increase maximum stack trace length.
// This helps diagnose infinite recursion bugs.
Error.stackTraceLimit = Infinity;
// Avoid warnings like "11 message listeners added to [Commander]. MaxListeners is 10."
// This is expected due to use of NestJS lifecycle hooks.
EventEmitter.defaultMaxListeners = 128;
}