Skip to content

Commit

Permalink
fix: quite max listeners warning
Browse files Browse the repository at this point in the history
Fixes #235
  • Loading branch information
harlan-zw committed Sep 20, 2024
1 parent 19b238b commit a44801d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/cli/src/ci.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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>', 'Budget (1-100), the minimum score which can pass.')
cli.option('--build-static <build-static>', 'Build a static website for the reports which can be uploaded.')
cli.option('--reporter <reporter>', 'The report to generate from results. Options: csv, csvExpanded, json, jsonExpanded or false. Default: json.')
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -14,6 +15,8 @@ async function run() {
if (options.help || options.version)
return

setMaxListeners(0)

const unlighthouse = await createUnlighthouse(
{
...pickOptions(options),
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/process/lighthouse.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { setMaxListeners } from 'node:events'
import fs from 'node:fs'
import { join } from 'node:path'
import lighthouse from 'lighthouse/core/index.cjs'
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.
*/
Expand Down

0 comments on commit a44801d

Please sign in to comment.