{"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":235,"sourceCode":"\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      browser.launchOptions.chromiumSandbox = browser.launchOptions.channel !== 'chromium' && browser.launchOptions.channel !== 'chrome-for-testing';\n    else\n      browser.launchOptions.chromiumSandbox = true;\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  }\n  if (browser.contextOptions.viewport === undefined) {\n    if (browser.launchOptions.headless)\n      browser.contextOptions.viewport = { width: 1280, height: 720 };\n    else\n      browser.contextOptions.viewport = null;","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/tools/mcp/config.ts#L217-L253","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":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}