豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

fix(cli): handle empty --browserUrl to prevent Invalid URL crash#270

Closed
yasirusman85 wants to merge 7 commits intoChromeDevTools:mainfrom
yasirusman85:fix-empty-browserurl
Closed

fix(cli): handle empty --browserUrl to prevent Invalid URL crash#270
yasirusman85 wants to merge 7 commits intoChromeDevTools:mainfrom
yasirusman85:fix-empty-browserurl

Conversation

@yasirusman85
Copy link
Copy Markdown

This PR fixes a startup bug in chrome-devtools-mcp where passing --browserUrl "" (as happens in VS Code Insiders with GitHub Copilot MCP integration) caused the process to exit with:

Invalid URL

Before fix

node build/src/index.js --browserUrl ""
# → Invalid URL, process exited with code 1

After fix

node build/src/index.js --browserUrl ""
# → Falls back to channel=stable, server starts successfully
chrome-devtools-mcp exposes content of the browser instance...

Root cause

  • cli.ts coerced even empty strings via new URL(url), which throws.
  • VS Code Insiders MCP integration sometimes passes --browserUrl "" instead of omitting the flag.

Fix

  • Updated coerce in cli.ts to safely ignore empty/blank strings.
  • Fallback logic now correctly assigns channel: "stable".

Impact

  • Fixes MCP server crash in VS Code Insiders.
  • Preserves existing behavior for valid URLs and other CLI options.

@yasirusman85 yasirusman85 changed the title Fix: handle empty --browserUrl to prevent Invalid URL crash fix(cli): handle empty --browserUrl to prevent Invalid URL crash Oct 4, 2025
@Lightning00Blade Lightning00Blade self-requested a review October 6, 2025 14:37
@Lightning00Blade
Copy link
Copy Markdown
Collaborator

@yasirusman85
Please remove all unrelated changes to the console, and after that I will be happy to review the PR.

@OrKoN
Copy link
Copy Markdown
Collaborator

OrKoN commented Oct 7, 2025

Closed via #298

@OrKoN OrKoN closed this Oct 7, 2025
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.

3 participants