From a44801d00cec3dcc61f1ad12f854786fdf761a9f Mon Sep 17 00:00:00 2001 From: harlan Date: Fri, 20 Sep 2024 17:52:10 +1000 Subject: [PATCH] fix: quite max listeners warning Fixes #235 --- packages/cli/src/ci.ts | 4 +++- packages/cli/src/cli.ts | 3 +++ packages/core/src/process/lighthouse.ts | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/ci.ts b/packages/cli/src/ci.ts index 1b2158ef..e27719f1 100644 --- a/packages/cli/src/ci.ts +++ b/packages/cli/src/ci.ts @@ -1,3 +1,4 @@ +import { setMaxListeners } from 'node:events' import { createUnlighthouse, generateClient, useLogger, useUnlighthouse } from '@unlighthouse/core' import fs from 'fs-extra' import { relative } from 'pathe' @@ -13,8 +14,9 @@ import type { CiOptions } from './types' async function run() { const startTime = new Date() - const cli = createCli() + setMaxListeners(0) + const cli = createCli() cli.option('--budget ', 'Budget (1-100), the minimum score which can pass.') cli.option('--build-static ', 'Build a static website for the reports which can be uploaded.') cli.option('--reporter ', 'The report to generate from results. Options: csv, csvExpanded, json, jsonExpanded or false. Default: json.') diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 3e59d11b..19da3338 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -1,3 +1,4 @@ +import { setMaxListeners } from 'node:events' import { createUnlighthouse, useLogger } from '@unlighthouse/core' import { createServer } from '@unlighthouse/server' import open from 'better-opn' @@ -14,6 +15,8 @@ async function run() { if (options.help || options.version) return + setMaxListeners(0) + const unlighthouse = await createUnlighthouse( { ...pickOptions(options), diff --git a/packages/core/src/process/lighthouse.ts b/packages/core/src/process/lighthouse.ts index 287b2bb2..a7bc3c92 100644 --- a/packages/core/src/process/lighthouse.ts +++ b/packages/core/src/process/lighthouse.ts @@ -1,3 +1,4 @@ +import { setMaxListeners } from 'node:events' import fs from 'node:fs' import { join } from 'node:path' import lighthouse from 'lighthouse/core/index.cjs' @@ -5,6 +6,8 @@ import minimist from 'minimist' import type { Flags } from 'lighthouse' import type { UnlighthouseRouteReport } from '../types' +setMaxListeners(0); + /* * This file is intended to be run in its own process and should not rely on any global state. */