micomec
micomec

Reputation: 71

How do I enable editable debugging of files within VS Code w/ Chrome Debugging?

Environment:


My action:

  1. {VSCode} Open the workspace containing my project directory.
  2. {VSCode} Add the following block to 'launch.json' in the "configurations" array:
{
   "type": "pwa-chrome",
   "request": "attach",
   "name": "Attach Chrome Debugging to Browser for VSCode",
   "port": 9222,
   "url": "http://localhost:8888/",
   "urlFilter": "http://localhost:8888/*",
   "webRoot": "${workspaceFolder}"
}
  1. {VSCode} Save 'launch.json'
  2. {Chrome} Close all running instances of Chrome
  3. {Terminal} Navigate to root (/)
  4. {Terminal} Run the command: /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=remote-debug-profile

Outcome:

  1. {Chrome} Application opens with a popup (not as expected):
    Screenshot of popup with text reading: "Google Chrome cannot read and write to its data directory: remote-debug-profile

My action:

  1. {Chrome} Click "Ok" button.

Outcome:

  1. {Chrome} A window opens prompting "Who's using Chrome?" with an option to select my desired user profile as expected.

My action:

  1. {Chrome} Click on my desired user profile.

Outcome:

  1. {Chrome} A window opens with my desired user profile logged in as expected.

My action:

  1. {VSCode} Add a breakpoint to my code via a debugger; statement in my HTML file.
  2. {VSCode} Click "Run" button with my debugging profile selected.
  3. {Chrome} Conduct behavior to trigger breakpoint in my code.

Outcome:

  1. {VSCode} The breakpoint is triggered HOWEVER: it is triggered in a "read-only" version of my file, opened in a new tab separate from my actual file.

My Desired Outcome

Using "attach" I want to be able to have the breakpoint activate inside of the actual file in VSCode, not a "Read-Only" version.


I've spent about two hours researching this issue and as far as I can tell it has to do with:

I'm at a total loss!

Upvotes: 3

Views: 912

Answers (1)

moi
moi

Reputation: 537

The problem is with --user-data-dir=remote-debug-profile

See here - https://chromium.googlesource.com/chromium/src/+/HEAD/docs/user_data_dir.md

You need to supply an actual directory path.

  1. Copy your current User Data folder to your custom dir

  2. Point chrome shortcut to the custom dir using the --user-data-dir parameter

Upvotes: 2

Related Questions