Skip to content

Commit a44801d

Browse files
committed
fix: quite max listeners warning
Fixes #235
1 parent 19b238b commit a44801d

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

packages/cli/src/ci.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { setMaxListeners } from 'node:events'
12
import { createUnlighthouse, generateClient, useLogger, useUnlighthouse } from '@unlighthouse/core'
23
import fs from 'fs-extra'
34
import { relative } from 'pathe'
@@ -13,8 +14,9 @@ import type { CiOptions } from './types'
1314
async function run() {
1415
const startTime = new Date()
1516

16-
const cli = createCli()
17+
setMaxListeners(0)
1718

19+
const cli = createCli()
1820
cli.option('--budget <budget>', 'Budget (1-100), the minimum score which can pass.')
1921
cli.option('--build-static <build-static>', 'Build a static website for the reports which can be uploaded.')
2022
cli.option('--reporter <reporter>', 'The report to generate from results. Options: csv, csvExpanded, json, jsonExpanded or false. Default: json.')

packages/cli/src/cli.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { setMaxListeners } from 'node:events'
12
import { createUnlighthouse, useLogger } from '@unlighthouse/core'
23
import { createServer } from '@unlighthouse/server'
34
import open from 'better-opn'
@@ -14,6 +15,8 @@ async function run() {
1415
if (options.help || options.version)
1516
return
1617

18+
setMaxListeners(0)
19+
1720
const unlighthouse = await createUnlighthouse(
1821
{
1922
...pickOptions(options),

packages/core/src/process/lighthouse.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import { setMaxListeners } from 'node:events'
12
import fs from 'node:fs'
23
import { join } from 'node:path'
34
import lighthouse from 'lighthouse/core/index.cjs'
45
import minimist from 'minimist'
56
import type { Flags } from 'lighthouse'
67
import type { UnlighthouseRouteReport } from '../types'
78

9+
setMaxListeners(0);
10+
811
/*
912
* This file is intended to be run in its own process and should not rely on any global state.
1013
*/

0 commit comments

Comments
 (0)