Get started

Recording console errors

Call this once, from client-side code, as early as your app can manage. Anything that happens before it is not in the buffer.

ts
import { initConsoleBuffer } from "bugbottle";

initConsoleBuffer();

Only error and warn are recorded, along with uncaught errors and unhandled promise rejections. log and debug are deliberately left alone: they are noisy, and in most applications they are where stray user data ends up. The original console functions are always called through, so nothing disappears from your devtools.

An uncaught error or a rejection also carries its stack, normalised to at most ten frames of { file, line, col, fn? } — V8, Firefox and Safari all write it differently, and one small parser reads all three. A frame is a position and nothing else: no line of source is ever read or sent, so resolving it stays your side, with your own source maps. Entries from console.error carry no frames; the browser gives none.

In a server-rendered app, make sure this runs in the browser only — it patches whichever console it finds.

Every recorder in the package returns its own stop, so a hot-reloaded module or a test can undo what it started without importing a second name:

ts
const stop = initConsoleBuffer();
stop(); // the real console back, the buffer empty

Edit this page on GitHub