{"record":{"id":"db90ddd98db3b954","repo":"microsoft/playwright","slug":"could-not-start-the-session-sessionname","errorCode":null,"errorMessage":"Could not start the session \"${sessionName}\"","messagePattern":"Could not start the session \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/tools/cli-client/registry.ts","lineNumber":85,"sourceCode":"\n  entry(clientInfo: ClientInfo, sessionName: string): SessionFile | undefined {\n    const key = clientKey(clientInfo);\n    const entries = this._files.get(key) || [];\n    return entries.find(entry => entry.config.name === sessionName);\n  }\n\n  entries(clientInfo: ClientInfo): SessionFile[] {\n    return this._files.get(clientKey(clientInfo)) || [];\n  }\n\n  entryMap(): Map<string, SessionFile[]> {\n    return this._files;\n  }\n\n  async loadEntry(clientInfo: ClientInfo, sessionName: string): Promise<SessionFile> {\n    const entry = await Registry._loadSessionEntry(clientInfo.daemonProfilesDir, sessionName + '.session');\n    if (!entry)\n      throw new Error(`Could not start the session \"${sessionName}\"`);\n\n    const key = clientKey(clientInfo);\n    let list = this._files.get(key);\n    if (!list) {\n      list = [];\n      this._files.set(key, list);\n    }\n    const oldIndex = list.findIndex(e => e.config.name === sessionName);\n    if (oldIndex !== -1)\n      list.splice(oldIndex, 1);\n    list.push(entry);\n    return entry;\n  }\n\n  private static async _loadSessionEntry(daemonDir: string, file: string): Promise<SessionFile | undefined> {\n    try {\n      const fileName = path.join(daemonDir, file);\n      const data = await fs.promises.readFile(fileName, 'utf-8');","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/tools/cli-client/registry.ts#L67-L103","documentation":"Thrown by Registry.loadEntry when Registry._loadSessionEntry returns no entry for the requested session file (sessionName + '.session' could not be read/parsed from the daemon profiles dir). It means the named session does not exist or its file is unreadable.","triggerScenarios":"Calling a session-scoped command (e.g. playwright-cli -s=myname <cmd>) when 'myname' has never been opened, was deleted, or its .session file is corrupt.","commonSituations":"Typo in the -s flag; running on a different machine / user account where the daemon profiles dir has no such session; the session file was hand-deleted; downgrading left the file unreadable.","solutions":["Create the session first with: playwright-cli -s=<name> open.","Verify the session file exists under the daemon profiles dir (clientInfo.daemonProfilesDir).","Drop the -s flag to operate on the 'default' session, or list sessions to confirm the name."],"exampleFix":"# before\nplaywright-cli -s=ci screenshot        # session 'ci' missing -> throws\n\n# after\nplaywright-cli -s=ci open               # create/launch the session\nplaywright-cli -s=ci screenshot         # now works","handlingStrategy":"validation","validationCode":"import fs from 'fs';\nimport path from 'path';\nfunction sessionExists(daemonProfilesDir: string, name: string): boolean {\n  return fs.existsSync(path.join(daemonProfilesDir, name + '.session'));\n}\nif (!sessionExists(info.daemonProfilesDir, name)) {\n  // run `playwright-cli -s=<name> open` instead of failing","typeGuard":"function isMissingSessionError(e: unknown): boolean {\n  return e instanceof Error && e.message.startsWith('Could not start the session');\n}","tryCatchPattern":"try {\n  await session.run(clientInfo, args);\n} catch (e) {\n  if (isMissingSessionError(e)) {\n    await Session.startDaemon(clientInfo, { session: name } as any, 'open');\n    await session.run(clientInfo, args); // retry after open\n  } else throw e;\n}","preventionTips":["Ensure `playwright-cli -s=<name> open` has been run before issuing commands.","When distributing across machines, recreate the session per machine rather than copying files."],"tags":["cli","session","daemon","state"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}