Skip to content

fix(cli): do not pass PLAYWRIGHT_CLI_SESSION as daemon --endpoint#41019

Open
Skn0tt wants to merge 1 commit into
microsoft:mainfrom
Skn0tt:fix-414
Open

fix(cli): do not pass PLAYWRIGHT_CLI_SESSION as daemon --endpoint#41019
Skn0tt wants to merge 1 commit into
microsoft:mainfrom
Skn0tt:fix-414

Conversation

@Skn0tt
Copy link
Copy Markdown
Member

@Skn0tt Skn0tt commented May 27, 2026

Summary

  • PLAYWRIGHT_CLI_SESSION was being passed to the daemon as --endpoint=<value> in attach mode, in addition to its correct use as the session name. The daemon then tried to connect to a socket at the literal session-name path.
  • Removed the vestigial fallback in startDaemon. resolveSessionName already consumes the env var with its documented meaning.

Fixes microsoft/playwright-cli#414

PLAYWRIGHT_CLI_SESSION is the env-var equivalent of -s/--session
(the session name). It is already consumed as such in startDaemon
via resolveSessionName. The leftover else-if branch additionally
re-passed it as the daemon's --endpoint= argument when mode is
'attach', which made the daemon try to connect to a socket at the
literal session-name path.

Repro:
  PLAYWRIGHT_CLI_SESSION=myname playwright-cli attach --cdp=http://127.0.0.1:99999
  -> Error: Daemon pid=...: connect ENOENT myname

The fallback dates back to microsoft#39650, when PLAYWRIGHT_CLI_SESSION
only meant "endpoint to attach to". After microsoft#39707 it gained its
current session-name meaning, but the obsolete fallback survived
through the --attach -> --endpoint rename (microsoft#39972) and the
mode-guard refactor (microsoft#40176).

Fixes microsoft/playwright-cli#414
@Skn0tt Skn0tt requested a review from pavelfeldman May 27, 2026 10:12
@github-actions
Copy link
Copy Markdown
Contributor

Test results for "MCP"

7188 passed, 1119 skipped


Merge workflow run.

args.push(`--cdp=${cliArgs.cdp}`);
if (cliArgs.endpoint)
args.push(`--endpoint=${cliArgs.endpoint}`);
else if (mode === 'attach' && process.env.PLAYWRIGHT_CLI_SESSION)
Copy link
Copy Markdown
Member

@pavelfeldman pavelfeldman May 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it break PLAYWRIGHT_CLI_SESSION=myname npx @playwright/cli attach? I think we are missing else in line 140 which would make --cdp, --cdp and --endpoint mutually exclusive.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That command doesn't work for me, here's the output on ToT:

 $ PLAYWRIGHT_CLI_SESSION=myname playwright-cli attach
 Error: no target specified for attach command; use one of [name], --cdp, --endpoint, or --extension to specify the target to attach to.

Maybe what you have in mind regressed in #39707?

@Skn0tt Skn0tt requested a review from pavelfeldman May 28, 2026 07:39
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.

PLAYWRIGHT_CLI_SESSION doesn't work with 'attach'

2 participants