ScreenshotNeo

BlogGuides

Puppeteer ConsoleMessageType: Console Message Types Explained

Learn the 19 Puppeteer console message types, read them from page events, and handle version differences between `warn` and `warning`.

By the ScreenshotNeo team4 October 20265 min read

Puppeteer’s ConsoleMessageType is a union of 19 literal strings in the 25.3.0 API reference: log, debug, info, error, warn, dir, dirxml, table, trace, clear, startGroup, startGroupCollapsed, endGroup, assert, profile, profileEnd, count, timeEnd, and verbose. To read one, listen for the page’s console event and call msg.type(). These values describe Puppeteer’s message-type union; they are not all severity levels. Puppeteer API reference.

What ConsoleMessageType means

A ConsoleMessage is an object dispatched by a page through its console event. Its type() method returns the message type. The same object exposes text(), args(), location(), and stackTrace() for inspecting message content and source context. The constructor is internal; consume messages from the event rather than creating them yourself. ConsoleMessage API reference.

The 19 message types in Puppeteer 25.3.0

Type What it indicates
log General console log operation
debug Debug output
info Informational output
error Error output
warn Warning output
dir Object inspection output
dirxml XML or DOM-oriented inspection output
table Tabular console output
trace Trace output
clear Console clear operation
startGroup Start a console group
startGroupCollapsed Start a collapsed console group
endGroup End a console group
assert Assertion-related output
profile Start profiling operation
profileEnd End profiling operation
count Counter operation
timeEnd End timing operation
verbose Verbose output

The descriptions above are practical cues from the names, not a guarantee that every browser or page will emit every type. In particular, values such as table, trace, clear, and group operations do not fit a simple severity ranking.

Listen for console messages in Puppeteer

JavaScript example:

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();

  page.on('console', msg => {
    console.log(`[${msg.type()}] ${msg.text()}`);
    console.log('location:', msg.location());
    console.log('stack:', msg.stackTrace());
  });

  await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
} finally {
  await browser.close();
}

This uses Puppeteer’s documented event and message methods. For an application that only needs the type and text, omit the location and stack calls:

page.on('console', msg => {
  console.log(msg.type(), msg.text());
});

Inspect arguments

args() returns handles for the console arguments. These can help when the text string does not preserve the shape of the original logged values. Handles are browser-side objects, so dispose of them when you explicitly acquire or retain them for longer-lived work. The API reference documents the method as returning argument handles; consult the installed version’s API details for handle operations.

Do not confuse message type with severity

Puppeteer’s ConsoleMessageType is a set of supported console message types. Chromium protocol declarations represent source and severity as separate concepts. Therefore, do not treat this Puppeteer union as a universal severity enum or assume a one-to-one mapping to protocol severity. Use type() for the Puppeteer message type and consult version-matched protocol documentation when you need protocol source or severity fields. Chromium protocol declarations.

Version differences: warn or warning

Exact spelling depends on the installed Puppeteer version. The current API reference at version 25.3.0 lists warn. The Puppeteer Core 21.6.1 declaration captured in the research lists warning. This evidence establishes a difference between those references, but not when or why it changed. Check the declaration for your installed package before comparing or filtering exact strings. Puppeteer 25.3.0 reference · Puppeteer Core 21.6.1 declaration.

Make filters tolerant when supporting multiple versions

const warningTypes = new Set(['warn', 'warning']);

page.on('console', msg => {
  if (warningTypes.has(msg.type())) {
    console.warn(msg.text());
  }
});

If your project supports one pinned version, prefer that version’s literal types and tests over accepting spellings from versions you do not support.

Common problems and fixes

Symptom Likely cause Fix
A comparison against warn misses warning messages The installed version’s declaration may use warning. Inspect the package declaration and handle the spelling used by that version.
Code expects a severity for every type The union includes operations such as groups, tables, clear, and trace. Use explicit handling for types your application needs; keep protocol severity separate.
Console output is absent The listener may be registered after navigation or after the page emitted messages. Attach page.on('console', ...) before calling goto().
Message text lacks useful object detail text() is a text representation, while original arguments are available separately. Inspect args() when structured arguments matter.
TypeScript rejects a string literal The literal does not belong to the installed version’s type union. Use the matching package types; do not silence the check without verifying runtime versions.

Practical handling guidance

  • Register listeners before navigation when you need page-load console output.
  • Record type() and text() for a compact diagnostic log; add location or stack data when investigating source context.
  • Avoid treating every non-error message as harmless. Decide based on the application’s needs and the message content.
  • Keep exact string checks aligned with the Puppeteer version in your lockfile.
  • For high-volume pages, avoid expensive processing in the event callback; enqueue selected fields and process them elsewhere.

Or skip the browser setup

If the task is to capture a page image or PDF rather than inspect browser console events, ScreenshotNeo provides a website screenshot API and MCP server. A single GET request returns an image or PDF. See the ScreenshotNeo API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
const bytes = new Uint8Array(await res.arrayBuffer());

ScreenshotNeo removes cookie banners, popups, and chat widgets before the shot. Bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month, no card required.

FAQ

What does ConsoleMessage.type() return?

It returns the message’s Puppeteer console type as a string, such as log, error, or table, according to the installed version’s supported type union.

Can I construct a ConsoleMessage myself?

The documented constructor is marked internal. Handle messages emitted by the page’s console event.

Is warn always the correct spelling?

No. The 25.3.0 reference lists warn; the 21.6.1 declaration lists warning. Use the declaration that matches your installed package.

Does every page emit all 19 types?

No such guarantee follows from the type union. It enumerates supported types; the messages you observe depend on page behavior.