Skip to content

LogFileWriter lowercases camelCase CDP console levels, so console.group/time/profile entries do not round-trip #1143

Open

Description

@latekvo

[Diplomat, Opus 5]: Found while verifying #1123 (the docs fix for #912), whose new test is the first place in the repo that enumerates the full Runtime.consoleAPICalled.type set.

LogFileWriter.write uppercases the level onto the flat line, and parseFlatLine (packages/tool-server/src/utils/debugger/log-file-writer.ts:245) recovers it with levelRaw.toLowerCase().trim(). That inverse is lossy for every CDP level that is not all-lowercase.

Driving the real writer over all 18 CDP console types, 5 fail to round-trip:

startGroup          -> startgroup
startGroupCollapsed -> startgroupcollapsed
endGroup            -> endgroup
profileEnd          -> profileend
timeEnd             -> timeend

The other 13 (log, debug, info, error, warning, dir, dirxml, table, trace, clear, assert, profile, count) survive.

Why it matters

createConsoleLogServer (js-runtime-debugger.ts:82, chromium-js-runtime-debugger.ts:66) replays the backlog through readAll() and then streams live entries straight off consoleAPICalled. A client that connects mid-session therefore sees "startgroup" for a console.group() that happened before it attached and "startGroup" for the identical call after - two different level strings for the same console API.

readFiltered({ level }) has the same hole (a filter for the canonical startGroup matches nothing), though today it has no production caller - only tests.

The existing regression test test/debugger/log-file-writer-level.test.ts states the contract as "The level must round-trip exactly for levels of any length", which these 5 falsify; its cases all happen to be lowercase.

Repro

const w = new LogFileWriter(59500);
w.write({ id: 0, timestamp: new Date().toISOString(), level: "startGroup", message: "x" });
w.readAll()[0].level; // "startgroup"

Activity

  1. added
    bugSomething isn't working
    b:minorBug that either affects a small cohort of users and affects a minor feature.
    on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    b:minorBug that either affects a small cohort of users and affects a minor feature.bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions