function flushConsoleHandlers
flushConsoleHandlers(
handlers?: Set<Promise<void>> | null,
page?: Page | null,
deadline?
): Promise<void>

Awaits all in-flight console handler promises until the Set is stably empty, recursing to catch handlers added by Firefox BiDi events that arrive during each await. The deadline (default 2 s) guards against infinite recursion.

Pass page whenever the caller is about to close the page/browser. The handlers Set can otherwise look empty here only because Chrome's Runtime.consoleAPICalled events are still in flight on the CDP WebSocket (a separate channel from QUnit's done WebSocket). A no-op page.evaluate request enforces FIFO drain on that CDP socket: its response cannot arrive before any earlier-queued events have been read by Playwright and dispatched to page.on('console'), so by the time it resolves every pending handler is in the Set. Without this, late console.log() output is lost when the page closes mid-flight under concurrent CI load.

await flushConsoleHandlers(new Set()); // resolves once the handler set is stably empty

Parameters

optional
handlers: Set<Promise<void>> | null
optional
page: Page | null
optional
deadline

Return Type

Promise<void>

Usage

import { flushConsoleHandlers } from "lib/commands/test/tests-in-browser.ts";