Skip to content

fix(cli): report command failures in text and JSON modes - #522

Merged
Pavel Feldman (pavelfeldman) merged 2 commits into
mainfrom
triage/502/42092304640-1
Nov 5, 2026
Merged

Pavel Feldman (pavelfeldman) merged 2 commits into
mainfrom
triage/502/42092304640-1

Conversation

@microsoft-playwright-automation

@microsoft-playwright-automation microsoft-playwright-automation Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The entry point discarded the promise from program(), so argument parsing, startup and daemon validation failures surfaced as unhandled rejections with a stack trace, and --json produced no output.
  • Await the program and report a failure as the message on stderr, or { "isError": true, "error": "..." } on stdout in JSON mode, with exit code 1. The output mode comes from the arguments parsed with the core's parseArgs() (chore: roll Playwright to 1.66.0-alpha-1793916328000 #523), read before program() runs; when parsing itself fails, it falls back to the --json flag.
  • Extend the open-data-URL test with the text and JSON parse error and a daemon-side validation error in JSON mode, and document the behavior.

Fixes #502

The entry point discarded the promise from program(), so argument
parsing, startup and daemon validation failures surfaced as unhandled
rejections with a stack trace, and `--json` produced no output. Report
them as a message on stderr, or `{ isError: true, error }` on stdout in
JSON mode, with exit code 1. The output mode comes from the parsed
arguments, or from the `--json` flag when parsing itself fails.

Fixes: #502
@pavelfeldman Pavel Feldman (pavelfeldman) changed the title fix(cli): handle command failures in text and JSON modes fix(cli): report command failures in text and JSON modes Nov 5, 2026
@pavelfeldman
Pavel Feldman (pavelfeldman) merged commit 34a4860 into main Nov 5, 2026
6 of 7 checks passed
@pavelfeldman
Pavel Feldman (pavelfeldman) deleted the triage/502/42092304640-1 branch November 5, 2026 23:09
bizya (b1zya) added a commit to b1zya/patchright-cli that referenced this pull request Nov 8, 2026
Resolves the blocked merge of tests/integration.spec.ts (b85c7a7 ->
4bc00fb). Upstream's update-check tests use an npm registry fixture; our
update check reads GitHub releases, so our cases stay. From microsoft#502 the
plain-mode --headed=false argument error is taken; the --json wrapping
(microsoft#522) is client code that arrives with a later patchright-core roll.

Closes #16
Closes #18
bizya (b1zya) added a commit to b1zya/patchright-cli that referenced this pull request Nov 8, 2026
Resolves the blocked merge of tests/integration.spec.ts (b85c7a7 ->
4bc00fb). Upstream's update-check tests use an npm registry fixture; our
update check reads GitHub releases, so our cases stay. From microsoft#502 the
plain-mode --headed=false argument error is taken; the --json wrapping
(microsoft#522) is client code that arrives with a later patchright-core roll.

Closes #16
Closes #18
Yury Semikhatsky (yury-s) pushed a commit that referenced this pull request Nov 10, 2026
## ✨ Highlights

- **🪟 Let agents use your logged-in browser without taking over your
screen**
([microsoft/playwright#42973](microsoft/playwright#42973))
— `PLAYWRIGHT_MCP_BACKGROUND=1 playwright-cli attach --extension=chrome`
keeps controlled tabs and the browser window in the background. You can
also set `"background": true` in your CLI config.
([microsoft/playwright#43864](microsoft/playwright#43864))
- **🎬 Record the whole viewport in headless Chrome and Edge** —
`playwright-cli video-start` no longer loses the bottom of the page to
browser-toolbar sizing in the new headless mode. Trace screenshots
benefit too.
([microsoft/playwright#43904](microsoft/playwright#43904))
- **🧭 Snapshots keep the names agents need**
([microsoft/playwright#43809](microsoft/playwright#43809))
— `playwright-cli snapshot` preserves identifying names on dialogs,
landmarks, tables and column headers, even when their heading or caption
also appears below them.
([microsoft/playwright#43810](microsoft/playwright#43810))
- **👁️ Ignore hidden duplicate elements by default**
([microsoft/playwright#43855](microsoft/playwright#43855))
— set `"browser": { "contextOptions": { "locateOnlyVisible": true } }`
in your CLI config, then run `playwright-cli open
--config=cli.config.json`. Locators resolve only visible matches,
avoiding strict-mode failures from hidden, cached UI. This is opt-in.
([microsoft/playwright#43903](microsoft/playwright#43903))
- **🗂️ Keep your tab strip free of agent-created groups**
([microsoft/playwright#43038](microsoft/playwright#43038))
— set `"tabGroup": false` in your CLI config and use `playwright-cli
attach --extension=chrome --config=cli.config.json`. Extension sessions
can control tabs without creating a Chrome tab group or changing your
existing groups.
([microsoft/playwright#43814](microsoft/playwright#43814))

## 🐛 Fixes

- `fix(cli): use ordinal filenames for repeated downloads` — repeated
downloads of `report.csv` become `report-1.csv`, `report-2.csv`, and so
on instead of silently overwriting earlier files.
([#514](#514),
[microsoft/playwright#44011](microsoft/playwright#44011))
- `fix(cli): restrict profile deletion to the exact session` —
`playwright-cli -s=work delete-data` no longer deletes the persistent
profile of `work-test`.
([#499](#499),
[microsoft/playwright#43928](microsoft/playwright#43928))
- `fix(cli): report command failures in text and JSON modes` — invalid
arguments and startup failures produce a readable error, or an `{
"isError": true, "error": "..." }` object with `--json`, and exit with
code 1 instead of exposing an unhandled rejection.
([#502](#502),
[#522](#522))
- `fix(cli): use CLI command names in error messages` — validation
errors and recovery hints name commands you can actually run, such as
`requests` and `recording-start`, rather than MCP tools, and avoid
doubled `Error:` prefixes.
([#515](#515),
[microsoft/playwright#43932](microsoft/playwright#43932))
- `fix(cli): avoid killing Windows process enumerators` —
`playwright-cli kill-all` correctly reports the daemons it stopped on
Windows instead of saying none were found.
([#525](#525),
[microsoft/playwright#44008](microsoft/playwright#44008))
- `fix(mcp): preserve non-JSON evaluation results` — `playwright-cli
eval '() => 10n'`, circular objects, regular expressions and special
numeric values are represented without turning successful evaluations
into serialization errors or losing their values. JSON-compatible
results retain their existing format.
([microsoft/playwright-mcp#1838](microsoft/playwright-mcp#1838),
[microsoft/playwright#43973](microsoft/playwright#43973))
- `fix(mcp): resolve config file paths relative to their source` —
relative profile, storage-state, executable and output paths now resolve
next to the config file, including `.playwright/cli.config.json` and
`~/.playwright/cli.config.json`, rather than the working directory.
Paths supplied through flags or environment variables remain relative to
the working directory.
([microsoft/playwright-mcp#1836](microsoft/playwright-mcp#1836),
[microsoft/playwright#43970](microsoft/playwright#43970))
- `fix(mcp): validate device names and preserve device descriptors` — an
unknown `--device` reports a clear error instead of silently disabling
emulation; context overrides no longer mutate shared device presets.
([microsoft/playwright-mcp#1834](microsoft/playwright-mcp#1834),
[microsoft/playwright#43971](microsoft/playwright#43971))
- `fix(mcp): bound settle waits when page timers cannot run` — commands
such as `eval` and `click` no longer hang during their post-action wait
on CSP-sandboxed pages or pages with paused clocks.
([microsoft/playwright#43752](microsoft/playwright#43752),
[microsoft/playwright#43767](microsoft/playwright#43767))
- `fix(mcp): report event listener exceptions as console errors` —
exceptions in page or context listeners registered with `run-code`
appear in console output instead of terminating the session.
([microsoft/playwright#43770](microsoft/playwright#43770),
[microsoft/playwright#43686](microsoft/playwright#43686))
- `fix(mcp): report one-based console source lines` — `playwright-cli
console` reports line numbers that match editors and DevTools.
([microsoft/playwright-mcp#1839](microsoft/playwright-mcp#1839),
[microsoft/playwright#43975](microsoft/playwright#43975))
- `fix(extension): report lost tab instead of crashing` — losing the
last controlled tab produces an actionable error instead of an
undefined-property exception, with guidance when another extension's
frame may have caused debugger detachment.
([microsoft/playwright#43230](microsoft/playwright#43230),
[microsoft/playwright#43863](microsoft/playwright#43863))
- `fix(chromium): honor Linux config directories for channel
connections` — browser discovery and attachment respect
`CHROME_CONFIG_HOME` and `XDG_CONFIG_HOME`; CDP connections also use the
WebSocket path recorded by Chrome instead of failing with a 404.
([microsoft/playwright#43880](microsoft/playwright#43880),
[microsoft/playwright#43884](microsoft/playwright#43884))
- `fix(chromium): preserve fonts when connecting with noDefaults` —
attaching to an existing headless browser preserves its font settings
and page layout.
([microsoft/playwright#43715](microsoft/playwright#43715),
[microsoft/playwright#43773](microsoft/playwright#43773))
- `fix(chromium): preserve HTTP navigations across HTTPS upgrade modes`
— explicit HTTP URLs and HTTP route mocks stay on HTTP instead of being
unexpectedly upgraded or failing in Chromium, Chrome and Edge.
([microsoft/playwright#43871](microsoft/playwright#43871),
[microsoft/playwright#43877](microsoft/playwright#43877))
- `fix(screenshot): support full-page SVG documents` — `playwright-cli
screenshot --full-page` captures standalone SVG documents instead of
timing out.
([microsoft/playwright#43962](microsoft/playwright#43962),
[microsoft/playwright#43972](microsoft/playwright#43972))
- `feat(actionability): wait for elements to be non-inert` — clicks,
fills and option selection wait for inert subtrees to become
interactive. Inert elements and content outside modal dialogs remain
available in snapshots and role locators.
([microsoft/playwright#43792](microsoft/playwright#43792),
[microsoft/playwright#43850](microsoft/playwright#43850),
[microsoft/playwright#43851](microsoft/playwright#43851))
- `fix(selectors): support labels for form-associated custom elements` —
label locators and accessible names recognize labels associated with
custom form controls.
([microsoft/playwright#43898](microsoft/playwright#43898),
[microsoft/playwright#43900](microsoft/playwright#43900))
- `fix(aria): match mixed-case selected options in accessible names` —
embedded comboboxes contribute their selected option's name even with
values such as `aria-selected="True"`.
([microsoft/playwright#43785](microsoft/playwright#43785),
[microsoft/playwright#43787](microsoft/playwright#43787))
- `fix(selector generator): do not throw when css fallback path is not
unique` — ambiguous matches in slotted web components report a useful
strict-mode error instead of a `TypeError`.
([microsoft/playwright#43701](microsoft/playwright#43701),
[microsoft/playwright#43705](microsoft/playwright#43705))
- `fix(frames): reject context waits when page closes` — pending
operations on an iframe whose document has not loaded fail when its page
closes instead of waiting indefinitely.
([microsoft/playwright#43647](microsoft/playwright#43647),
[microsoft/playwright#43650](microsoft/playwright#43650))
- `fix(install): report missing dependencies for all browsers` —
`playwright-cli install-browser` reports missing Linux dependencies
across browsers in one pass, including package names for Vulkan and
Graphene.
([microsoft/playwright#43747](microsoft/playwright#43747),
[microsoft/playwright#43750](microsoft/playwright#43750))

## 📦 Upgrading

```bash
npm install -g @playwright/cli@0.1.24
```

Co-authored-by: microsoft-playwright-automation[bot] <203992400+microsoft-playwright-automation[bot]@users.noreply.github.com>
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 crashes with a raw Node stack trace on any input error (and prints no JSON with --json)

1 participant