Repository navigation
Conversation
…-file puppeteerLogger() checked `logFileStream` truthiness before checking whether the namespace was DEBUG-enabled, so once --log-file was set, every CDP protocol message (puppeteer:protocol:SEND/RECV) was written unconditionally, ignoring DEBUG entirely. This is a regression from ChromeDevTools#2562 (replacing the `debug` npm package with Node's native util.debuglog): in v1.7.0, saveLogsToFile() called debug.enable() with the user's DEBUG namespaces plus mcp:log, so only explicitly enabled namespaces were written to the file. Reorder the check so DEBUG-enablement gates both branches, matching v1.7.0 behavior. logger() (the separate mcp:log function) is unaffected and correctly unconditional, since mcp:log was always in the enabled set even in v1.7.0.
Collaborator
|
Thank for the PR but there are simpler ways to test this. Please refer to #2743 |
zjdCander
pushed a commit
to zjdCander/chrome-devtools-mcp
that referenced
this pull request
Sep 14, 2026
…s#2743) Currently we unconditionally log all MCP and Puppeteer logs to the files. This adds regression test using mocks to simplify testings. Closes ChromeDevTools#2734 Closes ChromeDevTools#2706 Fixes ChromeDevTools#2731
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2731.
Problem
Since v1.8.0 (#2562, replacing the
debugnpm package with Node's nativeutil.debuglog),puppeteerLogger()insrc/utils/logger.tscheckslogFileStreamtruthiness before checking whether the namespace is DEBUG-enabled:So once
--log-fileis set, everypuppeteer:protocol:SEND/RECVmessage (full CDP JSON payloads — network events, accessibility trees, etc.) gets written to the log file regardless ofDEBUG, producing GB-scale log files instead of the KB-scale v1.7.0 behavior for the same traffic.In v1.7.0,
saveLogsToFile()calleddebug.enable()with the user'sDEBUGnamespaces plusmcp:log, so only explicitly-enabled namespaces were ever written —mcp:logalways (since it was always added to the enabled set), everything else only if the user opted in.Fix
Reordered
puppeteerLoggerto checkdbg.enabledfirst, so both the file-writing andutil.debuglog-writing branches are gated the same way — matching v1.7.0 semantics.logger()(the separate function backing the always-onmcp:lognamespace) is untouched; its unconditional file-write is correct, not a bug —mcp:logwas always in the enabled set even in v1.7.0.How did you test it
Added
tests/utils/logger.test.ts+ atests/utils/fixtures/puppeteer-logger-fixture.tshelper.util.debuglog(...).enabledreflectsNODE_DEBUGas of process start, not a value togglable at runtime, so the fixture is spawned as a fresh child process per case (4 cases: namespace disabled + log file → file stays empty; namespace enabled + log file → file gets the message;NODE_DEBUG=*+ log file → file gets the message; namespace disabled + no log file → returnsundefined, matching existing behavior).Verified fail-before/pass-after by running the equivalent logic directly against both the pre-fix and post-fix source (via
git stash) — pre-fix, the "disabled + log file" case wrongly writes to the file; post-fix, it doesn't.eslintandprettier --checkboth clean on all 3 changed/added files. I was not able to run the fullnpm test(tsc && node scripts/post-build.tsneeds thethird_party/devtools-frontendgit submodule, which failed to fetch in my environment — appears to be a shallow-submodule/pinned-commit mismatch, unrelated to this change) or the full projecttsc(blocked by the same missing submodule viasrc/third_party/index.ts's import of it). I isolated my 3 changed files with a standalonetsc --noEmitinvocation instead — confirmed zero type errors originate from any of them (the errors present in that run are 100% pre-existing, from unrelatedpuppeteer-core/rxjs/submodule type declarations, and disappear if those files are excluded). Happy to re-verify against a full build if a maintainer can point me at a working submodule fetch, or if this is a known environment quirk.