vscode-js-debug icon indicating copy to clipboard operation
vscode-js-debug copied to clipboard

Launch a new tab in the existing/running Chrome instance

Open OliverJAsh opened this issue 4 years ago • 3 comments

I have an instance of Chrome running with remote debugging enabled. I would like VS Code to launch a new tab (and/or window) in this instance and attach the debugger to it.

As far as I understand, the attach task is not what I need here, because this is intended for attaching to an existing tab.

I have tried using a launch task but it doesn't seem to open a new tab. Instead, it will navigate to url in the most recent tab, and then open a new blank tab.

{
    "type": "pwa-chrome",
    "request": "launch",
    "name": "Launch Chrome (existing)",
    "url": "http://localhost:5000",
    "webRoot": "${workspaceRoot}",
    // By default, the extension launches Chrome with a separate user profile in a temp folder. We
    // set it to `false` to launch with the default user profile instead, so we don't have to
    // reinstall extensions like React dev tools and re-configure any preferences.
    "userDataDir": false,
    "port": 9222
}

Is there a way to make it open a new tab instead?

OliverJAsh avatar May 06 '21 09:05 OliverJAsh

You can open a new tab manually in the browser and js-debug will attach to it. We don't have any automatic mechanism for this today, though.

connor4312 avatar May 06 '21 15:05 connor4312

UP here, would be awesome to change the user

otavioschwanck avatar Aug 08 '22 17:08 otavioschwanck

This is still not officially supported. I would expect running multiple launch chrome configs just opens tabs in one chrome window and attaches automatically. For example debugging multiple angular projects at once (one angular.json, multiple projects).

As a workaround I use this config:

"configurations": [
    {
      "name": "Launch app",
      "type": "chrome",
      "request": "launch",
      "preLaunchTask": "Build",
      "url": "http://localhost:4206",
      "runtimeArgs": ["http://localhost:4206"]
    },
    {
      "name": "Launch Panel",
      "type": "chrome",
      "request": "launch",
      "preLaunchTask": "Build Panel",
      "url": "http://localhost:4208",
      "webRoot": "${workspaceRoot}/projects/panel",
      "runtimeArgs": ["http://localhost:4208"]
    }
  ]

So there is a need to specify runtimeArgs (not needed for the config that is launched first), but there is an issue. When it launches second config, it shows error, but it still works normally.

image

jakubnavratil avatar Jul 20 '24 11:07 jakubnavratil