Skip to content

fix(chromium): honor CHROME_CONFIG_HOME and XDG_CONFIG_HOME for channel user data dirs - #43885

Closed
riccardofa (rickardof) wants to merge 1 commit into
microsoft:mainfrom
rickardof:fix-channel-user-data-dir-xdg
Closed

riccardofa (rickardof) wants to merge 1 commit into
microsoft:mainfrom
rickardof:fix-channel-user-data-dir-xdg

Conversation

@rickardof

Copy link
Copy Markdown

Fixes #43880

On Linux, connectOverCDP('chrome'), playwright-cli attach and the MCP extension look for the channel's user data dir in a hardcoded ~/.config/<product>. Chromium resolves it from $CHROME_CONFIG_HOME, then $XDG_CONFIG_HOME, then ~/.config, so with either variable set Playwright never finds DevToolsActivePort.

  • chromiumChannels.ts and channelSessions.ts: resolve the Linux config home the same way Chromium does. The two tables stay separate, as the "keep in sync" comment asks.
  • resolveChannelEndpoint: use the websocket path from the second line of DevToolsActivePort when present, and keep /devtools/browser as the fallback for port-only files. Without this, the right file is found but Chrome started with --remote-debugging-port answers 404.

Test. CD-054 launches a persistent context under <configHome>/google-chrome and connects from a child process, once with XDG_CONFIG_HOME and once with CHROME_CONFIG_HOME taking precedence. It is a new test rather than an extension of an existing one because it needs both a persistent context at a specific path and a fresh process, since the tables are built when the module loads. It fails without the change and passes with it.

Checked locally on Linux:

  • npm run ctest -- connect-over-cdp: 36 passed, 1 skipped, 1 failed. The failure is CD-004, which needs a Chromium executable I don't have installed; it fails the same way on main.
  • playwright-cli list --all --json with XDG_CONFIG_HOME set: finds the profile and its endpoint.
  • ESLint on the changed files and tsc: clean. I could not run the full npm run lint, because the doclint step needs network access that failed on my machine.

Not tested: macOS and Windows (the change only affects the Linux entries), and Chrome's chrome://inspect toggle flow, only --remote-debugging-port.

I reported this in #43880 and said I would wait for the assignment before opening a PR. I'm opening it now because the automated draft #43884 appeared for the same issue. I'd like to carry this one through and will address review comments; if you prefer the draft, that's your call and I'll close this.

…el user data dirs

On Linux, connectOverCDP('chrome') and 'playwright-cli attach' looked for
DevToolsActivePort in a hardcoded ~/.config/<product> directory, while
Chromium resolves its config dir from $CHROME_CONFIG_HOME, then
$XDG_CONFIG_HOME, then ~/.config.

Also use the websocket path from the second line of DevToolsActivePort
when present, since Chrome started with --remote-debugging-port rejects
/devtools/browser without the browser id.

Fixes microsoft#43880
@rickardof

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: connectOverCDP('chrome') ignores XDG_CONFIG_HOME / CHROME_CONFIG_HOME when locating DevToolsActivePort on Linux

2 participants