Skip to content

Updates DevToolsPlugin to not require browser to be closed #1156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions dev-proxy-plugins/Inspection/DevToolsPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,14 @@ private void InitInspector()
return;
}

// find if the process is already running
var processes = GetBrowserProcesses(browserPath);

if (processes.Any())
{
var ids = string.Join(", ", processes.Select(p => p.Id.ToString()));
Logger.LogError("Found existing browser process {processName} with IDs {processIds}. Could not start {plugin}. Please close existing browser processes and restart Dev Proxy", browserPath, ids, Name);
return;
}

var port = GetFreePort();
webSocket = new WebSocketServer(port, Logger);
webSocket.MessageReceived += SocketMessageReceived;
_ = webSocket.StartAsync();

var inspectionUrl = $"http://localhost:9222/devtools/inspector.html?ws=localhost:{port}";
var args = $"{inspectionUrl} --remote-debugging-port=9222 --profile-directory=devproxy";
var profilePath = Path.Combine(Path.GetTempPath(), "devtools-devproxy");
var args = $"{inspectionUrl} --remote-debugging-port=9222 --user-data-dir=\"{profilePath}\"";

Logger.LogInformation("{name} available at {inspectionUrl}", Name, inspectionUrl);

Expand Down