Skip to content

fix(mcp): merge user ignoreDefaultArgs with persistent mode defaults#40026

Open
lennondotw wants to merge 1 commit intomicrosoft:mainfrom
lennondotw:fix-ignore-default-args-persistent
Open

fix(mcp): merge user ignoreDefaultArgs with persistent mode defaults#40026
lennondotw wants to merge 1 commit intomicrosoft:mainfrom
lennondotw:fix-ignore-default-args-persistent

Conversation

@lennondotw
Copy link
Copy Markdown

Summary

In createPersistentBrowser, the hardcoded ignoreDefaultArgs: ['--disable-extensions'] was placed after ...config.browser.launchOptions in the object literal, silently overwriting any user-provided ignoreDefaultArgs from the config file. This meant users could not remove specific Chromium default arguments (e.g., --force-color-profile=srgb, --password-store=basic) when using persistent browser mode.

The fix merges the persistent mode's built-in ['--disable-extensions'] with the user's configured list (deduplicated via Set), and passes through ignoreDefaultArgs: true unchanged.

Details

Root cause: In browserFactory.ts, createPersistentBrowser constructs launchOptions as:

const launchOptions = {
  ...config.browser.launchOptions,   // user's ignoreDefaultArgs lands here
  ignoreDefaultArgs: ['--disable-extensions'],  // then gets overwritten here
};

Fix: Extract userIgnoreDefaultArgs before the spread, then merge:

  • true → passthrough (ignore all default args)
  • string[] → merge with ['--disable-extensions'] via Set (dedup)
  • undefined / unset → default behavior (['--disable-extensions'] only)

Isolated mode is unaffectedcreateIsolatedBrowser doesn't override ignoreDefaultArgs.

Test: End-to-end test in persistent mode: sets ignoreDefaultArgs: ['--password-store=basic'] via config, navigates to chrome://version, reads the command line, and verifies:

  • --password-store=basic is removed (user config honored)
  • --disable-extensions is removed (persistent mode built-in honored)
  • --use-mock-keychain is still present (other defaults preserved)

The hardcoded `ignoreDefaultArgs: ['--disable-extensions']` in
createPersistentBrowser was overwriting user-provided ignoreDefaultArgs
from the config file. Now the two lists are merged, and
`ignoreDefaultArgs: true` passes through correctly.
Copy link
Copy Markdown
Member

@Skn0tt Skn0tt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks for the PR!

],
ignoreDefaultArgs: userIgnoreDefaultArgs === true
? true
: [...new Set([
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for the Set, it's fine if there's duplicates in here.

throw new Error(`Browser is already in use for ${userDataDir}, use --isolated to run multiple instances of the same browser`);

const browserType = playwright[config.browser.browserName];
const userIgnoreDefaultArgs = config.browser.launchOptions?.ignoreDefaultArgs;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const userIgnoreDefaultArgs = config.browser.launchOptions?.ignoreDefaultArgs;
const configIgnoreDefaultArgs = config.browser.launchOptions?.ignoreDefaultArgs;

"user" is a synonym for "config" here, let's not add one more term to keep things simple

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants