Skip to content

[Bug]: electron.launch() fails with Electron 30+ - "bad option: --remote-debugging-port" #39008

@MihaiSora

Description

@MihaiSora

Version

1.58.0

Steps to reproduce

  1. Clone the reproduction repo
  2. npm install
  3. npm test
  4. Observe the error: bad option: --remote-debugging-port=0

Expected behavior

Electron app launches successfully and Playwright connects via CDP.

Actual behavior

Launch fails immediately with:

electron.launch: Process failed to launch!
Call log:
  - <launching> .../Electron.app/Contents/MacOS/Electron --inspect=0 --remote-debugging-port=0 main.js
  - [err] .../Electron.app/Contents/MacOS/Electron: bad option: --remote-debugging-port=0

The Electron binary rejects --remote-debugging-port=0 as an invalid CLI argument before any JavaScript executes.

Root cause: Playwright passes --remote-debugging-port=0 as a CLI argument, but Electron 30+ rejects this flag at the CLI level before the Node.js script starts.

Tested with both Playwright 1.57.0 and 1.58.0 - same issue.

Additional context

  • Electron docs list --remote-debugging-port as supported, but it only works via app.commandLine.appendSwitch() in Electron 30+, not as a CLI argument
  • This affects both the npm electron package and custom executablePath configurations
  • The nodeCliInspect fuse documentation doesn't mention --remote-debugging-port being affected
  • Workarounds attempted (all failed):
    • Pass flag after script path with -- → Flag ignored
    • Environment variable + app.commandLine.appendSwitch() in app → app.commandLine undefined due to ES module hoisting
    • Playwright's loader.js preload → Never executes because Electron rejects the flag first
  • Cypress documented similar issues: cypress-io/cypress#7994

Environment

System:
  OS: macOS 15.6.1
  CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Memory: 160.07 MB / 16.00 GB
Binaries:
  Node: 20.19.6 - /node/20.19.6/bin/node
  Yarn: 4.12.0 - /yarn/4.12.0/bin/yarn
  npm: 10.8.2 - /node/20.19.6/bin/npm
npmPackages:
  @playwright/test: 1.58.0
  electron: 36.9.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions