{"record":{"id":"9d312381268d0816","repo":"microsoft/playwright","slug":"browser-userdatadir-is-not-supported-in-isolated-m","errorCode":null,"errorMessage":"Browser userDataDir is not supported in isolated mode.","messagePattern":"Browser userDataDir is not supported in isolated mode\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/tools/mcp/config.ts","lineNumber":239,"sourceCode":"  return { channel: channel ?? 'chrome', executablePath, profileDirName };\n}\n\nasync function validateBrowserConfig(browser: MergedConfig['browser']): Promise<FullConfig['browser']> {\n  let browserName = browser.browserName;\n  if (!browserName) {\n    browserName = 'chromium';\n    // Assign channel only if the browserName is not provided, otherwise assume full control to the user.\n    if (browser.launchOptions.channel === undefined)\n      browser.launchOptions.channel = 'chrome';\n  }\n\n  if (browserName === 'chromium' && browser.launchOptions.chromiumSandbox === undefined) {\n    if (process.platform === 'linux') {\n      // Downloaded chromium builds (undefined channel, 'chromium', 'chrome-for-testing') lack the setuid sandbox helper on linux.\n      const { channel } = browser.launchOptions;\n      browser.launchOptions.chromiumSandbox = channel !== undefined && channel !== 'chromium' && channel !== 'chrome-for-testing';\n    } else {\n      browser.launchOptions.chromiumSandbox = true;\n    }\n  }\n\n  if (browser.isolated && browser.userDataDir)\n    throw new Error('Browser userDataDir is not supported in isolated mode.');\n\n  if (browser.initScript) {\n    for (const script of browser.initScript) {\n      if (!await fileExistsAsync(script))\n        throw new Error(`Init script file does not exist: ${script}`);\n    }\n  }\n  if (browser.initPage) {\n    for (const page of browser.initPage) {\n      if (!await fileExistsAsync(page))\n        throw new Error(`Init page file does not exist: ${page}`);\n    }\n  }","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/microsoft/playwright/blob/f1d33b5029be8bbc1095fe88e559117fa3a6243b/packages/playwright-core/src/tools/mcp/config.ts#L221-L257","documentation":"Thrown by `validateBrowserConfig` when both `browser.isolated` and `browser.userDataDir` are set. Isolated mode creates a fresh ephemeral context per session, which is incompatible with a fixed userDataDir (a persistent profile); the combination is contradictory and rejected at config validation time.","triggerScenarios":"Passing `--isolated` together with `--user-data-dir`/`--profile` on the CLI, or setting both `isolated: true` and `userDataDir` in a config file / env. The check fires during `validateBrowserConfig`, which runs on every MCP and CLI config resolution.","commonSituations":"A config file sets `isolated: true` and the CLI also passes `--profile`; env var enables isolated while a config file sets userDataDir; user misunderstands isolated mode and tries to pin a profile on top of it.","solutions":["Choose one: drop `--isolated` to use the persistent `userDataDir`, or remove `userDataDir`/`--profile` to use isolated ephemeral contexts.","Audit config file, CLI flags, and env vars for any source setting the conflicting option.","Remember isolated mode is for parallel/fresh sessions; userDataDir is for a stable persistent profile — they are mutually exclusive by design."],"exampleFix":"# before\nplaywright mcp --isolated --user-data-dir ~/profile\n# after (persistent)\nplaywright mcp --user-data-dir ~/profile\n# or (isolated)\nplaywright mcp --isolated","handlingStrategy":"validation","validationCode":"function validateBrowserOpts(opts: { isolated?: boolean; userDataDir?: string }) {\n  if (opts.isolated && opts.userDataDir)\n    throw new Error('Cannot combine isolated mode with a userDataDir; pick one.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick isolated OR persistent (userDataDir); never both.","Audit config file, CLI flags, and env for conflicting sources.","Treat isolated and userDataDir as mutually exclusive in your wrapper."],"tags":["config","isolated-mode","persistent-profile","validation","mutually-exclusive"],"backgroundTag":null,"analyzedSha":"f1d33b5029be8bbc1095fe88e559117fa3a6243b","analyzedAt":"2026-08-12T07:26:36.950Z","contentChangedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}