razor icon indicating copy to clipboard operation
razor copied to clipboard

Unable to debug Blazor wasm

Open samcarswell opened this issue 3 years ago • 8 comments

Describe the bug: Blazor wasm debugging no longer works in vscode. The below launch.json config previously worked:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch and Debug Standalone Blazor WebAssembly App",
            "type": "blazorwasm",
            "request": "launch",
            "cwd": "${workspaceFolder}",
            "browser": "edge"
        }
    ]
}

Version used:

  • VS Code Version:
Version: 1.61.0
Commit: ee8c7def80afc00dd6e593ef12f37756d8f504ea
Date: 2021-10-07T18:11:58.853Z
Electron: 13.5.1
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin x64 20.6.0
  • OS Version: macOS 11.6 (20G165)
  • dotnet version: 5.0.400

To reproduce: Steps to reproduce the behavior:

  1. Add the above debug config
  2. Run the debug config

Expected behavior: Edge to launch my application and the debugger to successfully be attached to it.

Actual behavior: Gives me the following message: image

Clicking Debug anyway does not work.

Additional context: The first time i used the above config, browser was set to chrome and this did not work even the first time running it: it would produce the same message above. Changing it to edge worked at first and then began giving the same issue.

samcarswell avatar Oct 13 '21 23:10 samcarswell

@danroth27 @captainsafia Is this known / have you heard things similar?

NTaylorMullen avatar Oct 14 '21 21:10 NTaylorMullen

Adding @mkArtakMSFT @lewing.

danroth27 avatar Oct 15 '21 02:10 danroth27

cc @thaystg @ilonatommy

lewing avatar Oct 15 '21 15:10 lewing

Might also be worthwhile to include @connor4312 in case this is an issue with the way the JS debugger manages state of open browsers.

captainsafia avatar Oct 15 '21 20:10 captainsafia

It sounds like you're not closing the browser completely. The browser must be closed so that its icon no longer appears in the dock, it's not sufficient for all windows to be closed.

connor4312 avatar Oct 15 '21 20:10 connor4312

It sounds like you're not closing the browser completely. The browser must be closed so that its icon no longer appears in the dock, it's not sufficient for all windows to be closed.

Just confirming that the browser is definitely closed before running the debugger. Even restarting my machine completely - and not opening Edge or Chrome before debugging - produces the same result.

samcarswell avatar Oct 18 '21 04:10 samcarswell

I get the same issue using Chrome on Ubuntu 18.04. Obviously I cannot test with Edge, but my understanding is Chrome should be supported on Ubuntu. Versions are:

  • Ubuntu 18.04
  • Chrome 94.0.4606.81
  • dotnet 5.0.401
  • VSCode 1.61.0 (ee8c7def80afc00dd6e593ef12f37756d8f504ea, x64)

claresloggett avatar Oct 26 '21 00:10 claresloggett

I also had this problem on linux and chromium. I found a workaround is to use Edge instead, see my answer on StackOverflow for working config.

lonix1 avatar Apr 28 '22 03:04 lonix1

I also had this problem on linux and chromium. I found a workaround is to use Edge instead, see my answer on StackOverflow for working config.

This does seem to be a temporary workaround, though I would much prefer to be able to debug in Chromium, or better yet, Brave or Firefox.

I don't know if the issue is related, but the debugger does not seem to exit the application when running a blazorwasm launch configuration either. I have to manually kill the process via a program like htop or btop, even after clicking the "Stop" button of the Debugging menu in Code. This is only an issue with the blazorwasm configuration, as coreclr quits the application correctly. However, obviously, coreclr does not debug WASM.

This means regular development and workflow requires a coreclr launch configuration, and then a separate blazorwasm configuration to switch to if a WASM specific issue requires debugging. This means a degraded debugging experience no matter which option is used.

incomingstick avatar Mar 06 '23 22:03 incomingstick

Chromium support is only enabled on .net8 preview 1 or using DevServer package version 7.0.3 if you are using .net7.

thaystg avatar Mar 06 '23 22:03 thaystg

Chromium support is only enabled on .net8 preview 1 or using DevServer package version 7.0.3 if you are using .net7.

Just updated and Chromium debugging does work. However it still does not close the application properly when clicking the square "Stop" button in the debug menu. I can confirm I am not clicking Disconnect, which is ultimately still the behavior I experience. Its as though it's just detaching. The debugger stops, but the application continues running. I have to manually kill the process in order to launch and debug again.

Even after killing the process, and ensuring no Chromium process is running, I will always receive this pop up, as well as the first time debugging after a reboot:

Screenshot_20230306_162400

As a workaround, I have tried setting up a postDebugTask that calls pkill, however it does not seem like the task fires. No output for the task is shown, or even started, in the integrated terminal, and the process can still be seen running. I can manually run the task from the Command Center, however.

incomingstick avatar Mar 06 '23 22:03 incomingstick

As a workaround, I have tried setting up a postDebugTask that calls pkill, however it does not seem like the task fires. No output for the task is shown, or even started, in the integrated terminal, and the process can still be seen running. I can manually run the task from the Command Center, however.

It actually looks like no tasks run at all using the blazorwasm launch configuration. I tried adding my "preLaunchTask": "build" that runs successfully using the coreclr launch configuration, and it does not fire either.

Edit: I found this:

How are you setting the preLaunchTask? It should work if you nest it with the dotnetConfig property in your launch settings like so:

{
  type: "blazorwasm",
  dotnetConfig: {
    preLaunchTask: ...,
  }
}

Originally posted by @captainsafia in https://github.com/dotnet/razor/issues/5721#issuecomment-967311455

Which does allow me to run the kill task after stopping the debug session, however this does not prevent the pop-up in my image above. It at least allows me to re-launch debugging without having to manually kill the process.

incomingstick avatar Mar 06 '23 22:03 incomingstick