Vscode-js-debug: Launchservices causes timeout discovering browsers on OSX

Created on 10 Jul 2020  路  18Comments  路  Source: microsoft/vscode-js-debug

Describe the bug
Debugging via chrome appears to broken after upgrade.

To Reproduce
Steps to reproduce the behavior:

  1. Goto debug section
  2. Click settings and add basic Launch Chrome
  3. Click run
  4. See error:
Error processing launch: Error: Could not attach to main target
    at Object.t.timeoutPromise (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:1:33028)
    at f.prepareLaunch (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:15:2619737)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
    at async f.launch (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:15:2620329)
    at async t.Binder.captureLaunch (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:73:25637)
    at async t.Binder._launch (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:73:25208)
    at async Promise.all (index 6)
    at async t.Binder._boot (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:73:24468)
    at async t.default._onMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:15:2459238)

Log File

Gz json file seems to be corrupt.

VS Code Version: 1.47.0

Additional context
MacOSX

bug

Most helpful comment

This will be fixed in today's nightly build (published at 5 PM PST). Thank you for your help in diagnosing this!

All 18 comments

@markmcdowell this indicates that the debugger could not find a page matching the "urlFilter" given in your launch config within 10 seconds.

Could you share your launch config?

The launch config was the default generated.

Tried with:

{
  "name": "Launch Chrome",
   "request": "launch",
   "type": "pwa-chrome",
   "url": "http://localhost:8080",
   "webRoot": "${workspaceFolder}"
}

and

{
   "type": "chrome",
   "request": "launch",
   "name": "Launch Chrome",
   "sourceMaps": true,
   "url": "http://localhost:8000",
   "webRoot": "${workspaceFolder}"
}

I think the issue is actually https://github.com/microsoft/vscode-chrome-debug/issues/1023 I've downgraded the Debugger for Chrome and all working again.

Can you enable trace: true and share the resulting log file? Even if it's corrupt, it's fine.

Thanks! Looks like a different problem than the issue you linked. Someone reported it a few days ago, also on OSX, but I wasn't able to root cause it yet.

Could you please try installing this build of the extension https://memes.peet.io/img/js-debug-for-issue-570.vsix (downloading it and then running "Install from VSIX" on the command palette/cmd+shift+p) and capturing trace logs again? That will help me narrow down where it's getting hung up.

Can you try that again and check this box temporarily?

I built this off master which is version 1.47.2 while stable is a hotfix ahead at version 1.47.3 -- from the logs it looks like it auto-updated right after you installed it 馃槢

Ah ok, I've reinstalled and made sure it's still on 1.47.2 and generated these logs:

vscode-debugadapter-0.json.gz

Okay, thanks!

It looks like the thing eating up time for you is trying to find the path to Chrome on your machine. To do this we read output from OSX' launch services tool. You should be able to get around this by either:

  • Increasing the timeout property of your launch.json, e.g. to 20 seconds from 10 seconds timeout: 20000
  • Manually specifying the path to Chrome in the runtimeExecutable which will avoid having to run discovery logic.

This seems to have a pretty low incidence rate; I think a decent solution here is caching the browser path to avoid needing to look up multiple times. It will still time out once in this case, but should thereafter work.

Yeah specifying 20 seconds makes it work, just to note with v4.12.8 of the debugger for chrome it starts straight away without any delay.

Yea, the previous debugger just probed pre-set paths. The downside is that if you have the browser installed on some non-default path, you would of course need to fiddle with configuration. But we could also do the probing to provide fast launches for common cases

This will be fixed in today's nightly build (published at 5 PM PST). Thank you for your help in diagnosing this!

@connor4312 Hey there. I've bumped into the same issue
Error processing launch: Error: Could not attach to main target at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:1:33351 when I try to open in debug mode. I've tried to extend the timeout: 20000 but the above error still persists.

@stanimiryakimov thanks for the report, are you able to collect a trace log using these instructions?

If you're able to, add "trace": true to your launch.json and reproduce the issue. The location of the log file on your disk will be written to the Debug Console. Share that with us.

鈿狅笍 This log file will not contain source code, but will contain file paths. You can drop it into https://microsoft.github.io/vscode-pwa-analyzer/index.html to see what it contains. If you'd rather not share the log publicly, you can email it to [email protected]

As per blog https://medium.com/young-coder/setting-up-javascript-debugging-in-visual-studio-code-6c5005529987, tried debugging simple HTML, CSS and plain JS project but consistently getting error as below.

getting below error

Mac 10.13.6 + VS Code 1.47.3 + Debugger for chrome 4.12.9

launch.json

"version": "0.2.0", "configurations": [ { "type": "chrome", "request": "launch", "name": "Launch Chrome against localhost", "file": "${workspaceFolder}" } ]

Error dialog

Error processing launch: Error: Could not attach to main target at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:1:33351 at async _.prepareLaunch (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:15:2620406) at async _.launch (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:15:2621006) at async t.Binder.captureLaunch (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:73:25725) at async t.Binder._launch (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:73:25296) at async Promise.all (index 6) at async t.Binder._boot (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:73:24556) at async t.default._onMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js:15:2459787)

@connor4312 please re-open ticket as issue still exists

I soulved by removing http:// from url

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ArzelaAscoIi picture ArzelaAscoIi  路  5Comments

jaadh picture jaadh  路  3Comments

baptoutiego picture baptoutiego  路  3Comments

michaelhyman picture michaelhyman  路  5Comments

roblourens picture roblourens  路  5Comments