{"record":{"id":"9e83a7042402eec9","repo":"microsoft/playwright","slug":"launching-more-browsers-is-not-allowed-9e83a7","errorCode":null,"errorMessage":"Launching more browsers is not allowed.","messagePattern":"Launching more browsers is not allowed\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/dispatchers/electronDispatcher.ts","lineNumber":41,"sourceCode":"import type { PageDispatcher } from './pageDispatcher';\nimport type { ConsoleMessage } from '../console';\nimport type { Electron } from '../electron/electron';\nimport type * as channels from '../channels';\nimport type { Progress } from '../progress';\n\n\nexport class ElectronDispatcher extends Dispatcher<Electron, channels.ElectronChannel, RootDispatcher> implements channels.ElectronChannel {\n  _type_Electron = true;\n  _denyLaunch: boolean;\n\n  constructor(scope: RootDispatcher, electron: Electron, denyLaunch: boolean) {\n    super(scope, electron, 'Electron', {});\n    this._denyLaunch = denyLaunch;\n  }\n\n  async launch(params: channels.ElectronLaunchParams, progress: Progress): Promise<channels.ElectronLaunchResult> {\n    if (this._denyLaunch)\n      throw new Error(`Launching more browsers is not allowed.`);\n    const electronApplication = await this._object.launch(progress, params);\n    return { electronApplication: new ElectronApplicationDispatcher(this, electronApplication) };\n  }\n}\n\nexport class ElectronApplicationDispatcher extends Dispatcher<ElectronApplication, channels.ElectronApplicationChannel, ElectronDispatcher> implements channels.ElectronApplicationChannel {\n  _type_EventTarget = true;\n  _type_ElectronApplication = true;\n  private readonly _subscriptions = new Set<channels.ElectronApplicationUpdateSubscriptionParams['event']>();\n\n  constructor(scope: ElectronDispatcher, electronApplication: ElectronApplication) {\n    super(scope, electronApplication, 'ElectronApplication', {\n      context: BrowserContextDispatcher.from(scope, electronApplication.context())\n    });\n    this.addObjectListener(ElectronApplication.Events.Close, () => {\n      this._dispatchEvent('close');\n      this._dispose();\n    });","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/dispatchers/electronDispatcher.ts#L23-L59","documentation":"Thrown by ElectronDispatcher.launch() when _denyLaunch is true. ElectronDispatcher gets the same denyLaunch policy as BrowserType/Android dispatchers: a Playwright server that owns lifecycle (or a restricted connection) forbids the client from launching additional Electron applications. The check runs before any electron.spawn.","triggerScenarios":"Calling playwright.electron.launch() (the Electron RPC) through a RootDispatcher/ElectronDispatcher constructed with denyLaunch=true — i.e. over a connection to a managed/restricted Playwright server. Fires immediately, before the Electron binary is located or spawned.","commonSituations":"Running Electron automation against a remote/restricted Playwright server that did not pre-authorize Electron launches; MCP/grid sessions with denyLaunch that try to start Electron from the client.","solutions":["Run electron.launch() from a local, unconstrained playwright instance rather than through a denyLaunch server connection.","If the server is meant to provide Electron, have it pre-launch and hand the application back through the init result instead of letting the client spawn it.","Switch the server to a mode without denyLaunch when client-side Electron launches are required."],"exampleFix":"// before: launch Electron through a restricted server connection\nconst electron = (await playwright.connect(server)).electron;\nconst app = await electron.launch(); // denied\n\n// after: launch Electron from a local instance\nconst { electron } = require('playwright');\nconst app = await electron.launch({ executablePath: '/path/to/app' });","handlingStrategy":"validation","validationCode":"if (init.denyLaunch) throw new Error('Server denies electron.launch(); run Electron from a local playwright instance');","typeGuard":null,"tryCatchPattern":"try {\n  await playwright.electron.launch();\n} catch (e) {\n  if (/Launching more browsers is not allowed/.test(e.message)) { /* use local instance */ }\n  else throw e;\n}","preventionTips":["Launch Electron from a local, unconstrained playwright instance, not through a managed server connection.","If the server must provide Electron, have it pre-launch and hand the application back via the init result.","Surface denyLaunch at connect time so operators route Electron launches correctly."],"tags":["electron","deny-launch","server","remote","launch"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}