In Atom, I'm able to debug installed extensions by opening the developer tools (Option+Cmd+I) and browsing through JavaScript files in ~/.atom/packages
, e.g.
Is it possible to do this in VSCode? After opening the developer tools via Help -> Toggle Developer Tools, the only extension-related files I can find are the icon images:
VS Code's built-in debugging functionality makes it easy to debug extensions. Set a breakpoint by clicking the gutter next to a line, and VS Code will hit the breakpoint. You can hover over variables in the editor or use the Run and Debug view in the left to check a variable's value.
Navigate to the chrome extensions management page at chrome://extensions and ensure developer mode is on. Click the Load Unpacked button and select the broken extension directory. After the extension is loaded, it should have three buttons: Details, Remove and Errors in red letters.
Bring up the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of VS Code or the View: Extensions command (Ctrl+Shift+X). This will show you a list of the most popular VS Code extensions on the VS Code Marketplace.
The solution was to go to Windows PowerShell and open Visual Studio Code, then go to the extensions and restart the Remote - WSL extension, and go back to WSL. It then started working immediately.
You can easily run your extension under the debugger by pressing F5. This opens a new VS Code window with your extension loaded. from your extension shows up in the Debug Console. You can set break points, step through your code, and inspect variables either in the
VS Code ships with one built-in debugger extension, the Node.js debugger extension, which is an excellent showcase for the many debugger features supported by VS Code: This screenshot shows the following debugging features:
You can browse and install extensions from within VS Code. Bring up the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of VS Code or the View: Extensions command (⇧⌘X (Windows, Linux Ctrl+Shift+X)). This will show you a list of the most popular VS Code extensions on the VS Code Marketplace.
Once the Extension Host is launched, VS Code attaches the debugger to it and starts the debug session. This is what happens when pressing F5 : 1. .vscode/launch.json instructs to first run a task named npm . 2. .vscode/tasks.json defines the task npm as a shell command to npm run compile . 3.
$ PID=$(pgrep -f "^/Applications/Visual Studio Code\.app/.*--type=extensionHost")
$ echo $PID
35791
Argument -f
tells pgrep
to match the pattern against the full process argument string, not just the process name.
$ kill -SIGUSR1 $PID
(This produces no output.)
lsof
:$ lsof -p $PID -a -i4tcp
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Code\x20H 35791 tim.vergenz 58u IPv4 0x8af67df8a9aa26a8 0t0 TCP localhost:63767 (LISTEN)
Argument explanations:
-p
means filter by PID-i4tcp
means filter by Internet address (4tcp
means only IPv4 / tcp protocl)-a
in between combines the two filters via AND instead of the default ORIn the "NAME" column you'll find the host and port that your VS Code extension host process is listening on -- i.e. in the example above, localhost:63767
.
You may need to manually add ~/.vscode/extensions
to your workspace in order to browse files and add breakpoints:
... and click "Allow" to grant it permission:
Your code doesn't show in the main developer tools because VSCode unfortunately runs extensions in a separate process called the Extension Host.
You can go to Help > Process Explorer to look up the Extension Host process id, then kill -sigusr1
it to turn on its debugger (like any node process). Then in Chrome, go to chrome://inspect
and you should see the process (it won't look very recognizable, the name will be something like /private/var/folders/f3/zmhpprp15zxfd1s3fpp3prm80000gn/T/AppTranslocation/C0D80599-1ECA-4802-A110-A1…
)
I'm not 100% sure if all extension code is available in that debugger because it has subprocesses, but so far I've been able to set breakpoints in some of my installed extensions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With