fix(listeners): avoid "too many listeners" problem safely (#4223)

This commit is contained in:
Pavel Feldman 2020-10-23 10:38:26 -07:00 committed by Andrey Lushnikov
parent 3201c238cf
commit 3188d6ecbe

View file

@ -58,6 +58,12 @@ export async function gracefullyCloseAll() {
await Promise.all(Array.from(gracefullyCloseSet).map(gracefullyClose => gracefullyClose().catch(e => {})));
}
// We currently spawn a process per page when recording video in Chromium.
// This triggers "too many listeners" on the process object once you have more than 10 pages open.
const maxListeners = process.getMaxListeners();
if (maxListeners !== 0)
process.setMaxListeners(Math.max(maxListeners || 0, 100));
export async function launchProcess(options: LaunchProcessOptions): Promise<LaunchResult> {
const cleanup = () => helper.removeFolders(options.tempDirectories);