{"record":{"id":"5a68aa3dcb16483c","repo":"microsoft/playwright","slug":"browser-this-name-is-not-open-run-playwri","errorCode":null,"errorMessage":"Browser '${this.name}' is not open. Run\n\n  playwright-cli${this.name !== 'default' ? ` -s=${this.name}` : ''} open\n\nto start the browser session.","messagePattern":"Browser '(.+?)' is not open\\. Run\n\n  playwright-cli(.+?)` : ''\\} open\n\nto start the browser session\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/tools/cli-client/session.ts","lineNumber":51,"sourceCode":"  private _sessionFile: SessionFile;\n\n  constructor(sessionFile: SessionFile) {\n    this.config = sessionFile.config;\n    this.name = this.config.name;\n    this._sessionFile = sessionFile;\n  }\n\n  isCompatible(clientInfo: ClientInfo): boolean {\n    return compareSemver(clientInfo.version, this.config.version) >= 0;\n  }\n\n  async run(clientInfo: ClientInfo, args: MinimistArgs, options?: { raw?: boolean, json?: boolean }): Promise<{ text: string, isError?: boolean }> {\n    if (!this.isCompatible(clientInfo))\n      throw new Error(`Client is v${clientInfo.version}, session '${this.name}' is v${this.config.version}. Run\\n\\n  playwright-cli${this.name !== 'default' ? ` -s=${this.name}` : ''} open\\n\\nto restart the browser session.`);\n\n    const { socket } = await this._connect();\n    if (!socket)\n      throw new Error(`Browser '${this.name}' is not open. Run\\n\\n  playwright-cli${this.name !== 'default' ? ` -s=${this.name}` : ''} open\\n\\nto start the browser session.`);\n    return await SocketConnectionClient.sendAndClose(socket, 'run', { args, cwd: process.cwd(), raw: options?.raw, json: options?.json });\n  }\n\n  async stop(): Promise<{ wasOpen: boolean }> {\n    if (!await this.canConnect())\n      return { wasOpen: false };\n    await this._stopDaemon();\n    return { wasOpen: true };\n  }\n\n  async deleteData(): Promise<{ existed: boolean, deletedUserDataDir: boolean }> {\n    await this.stop();\n\n    const dataDirs = await fs.promises.readdir(this._sessionFile.daemonDir).catch(() => []);\n    const matchingEntries = dataDirs.filter(file => file === `${this.name}.session` || file.startsWith(`ud-${this.name}-`));\n    if (matchingEntries.length === 0)\n      return { existed: false, deletedUserDataDir: false };\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/tools/cli-client/session.ts#L33-L69","documentation":"Thrown by Session.run after the compatibility check passes but _connect() returns no socket — meaning the named session file exists and is version-compatible, but no daemon process is listening on the configured socketPath (the daemon was never started, has exited, or crashed).","triggerScenarios":"Calling any session-scoped command when the daemon for that session is not running; the daemon died after the session file was written; the machine rebooted leaving a stale session file.","commonSituations":"Reboot/logoff killed the daemon; an earlier open failed silently; long gap between open and the command; OS cleaned up the socket path.","solutions":["Run playwright-cli open (add -s=<name> if non-default) to (re)start the daemon.","If open claims it is already running but the socket is dead, run session.stop()/close first to clean up, then open.","Check the .err log under clientInfo.daemonProfilesDir for the crash cause if the daemon keeps dying."],"exampleFix":"# before\nplaywright-cli -s=ci screenshot   # daemon not running -> throws\n\n# after\nplaywright-cli -s=ci open\nplaywright-cli -s=ci screenshot","handlingStrategy":"validation","validationCode":"// Probe the socket before issuing the command.\nconst canConnect = await session.canConnect(); // returns boolean, no throw\nif (!canConnect) {\n  await Session.startDaemon(clientInfo, { session: session.name } as any, 'open');\n}","typeGuard":"function isBrowserNotOpenError(e: unknown): boolean {\n  return e instanceof Error && e.message.includes(\"is not open\");\n}","tryCatchPattern":"try {\n  await session.run(clientInfo, args);\n} catch (e) {\n  if (isBrowserNotOpenError(e)) {\n    await Session.startDaemon(clientInfo, { session: session.name } as any, 'open');\n    await session.run(clientInfo, args);\n  } else throw e;\n}","preventionTips":["Call session.canConnect() before session.run() to detect a dead daemon upfront.","Inspect the <name>.err log in the daemon profiles dir if the daemon repeatedly fails to start.","Pair every open with an explicit close in long-lived environments."],"tags":["session","daemon","connection","cli"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}