Problems with Debugging Dashboards in Development

Product: PowerShell Universal
Version: 3.5.4

I feel like I’m missing something here but I’ve been trying to develop and debug PSU Dashboards for around a year now but I’ve found debugging dashboard is extremely problematic to the point I simply can’t use the feature, I’m trying to work out if I’m just doing something wrong.

Too often a dashboard will simply have a header off “Error with dashboard script” with nothing listed in Dashboard Log, no Write-* Cmdlets, or other Cmdlets, seem to have run, no exceptions, no errors, nothing from pipeline, it leaves me with no information on what has actually gone wrong.

For those Dashboard scripts running well enough to get pass that issue; if I use Wait-Debugger to trigger a breakpoint, Enter-PSHostProcess of the relevant process and use Debug-Runspace on the runspace with the breakpoint, I will often get no output or shell, making the breakpoint useless.

I also notice if I restart a Dashboard script often enough, it will eventually have some sort of silent issue where it will no longer start properly (despite saying it’s “Started”), acting as if no Cmdlets are being run at all. The only way to fix this is to restart the PowerShellUniversal Windows Service.

No error information, unreliable breakpoints and a finite limit to how many dashboard restarts in one lifespan of the PSU service… does anyone else have these issues? How are other people debugging their dashboards during development? How can I begin to troubleshooting some of these issues?

Is no one else experiencing these problems?

Too often a dashboard will simply have a header off “Error with dashboard script” with nothing listed in Dashboard Log, no Write-* Cmdlets, or other Cmdlets, seem to have run, no exceptions, no errors, nothing from pipeline, it leaves me with no information on what has actually gone wrong.

This is usually due to syntax issues or no dashboard hashtable (New-UDDashboard) being returned from the dashboard script. Sometimes dropping other things on the pipeline, outside of New-UDDashboard, can cause this issue as well. We should definitely improve this with a valid error message on the dashboard. That said, I always see an error in the dashboard log when this happens so I’m not exactly sure why you’d be encountering this so often.

I honestly think we should prevent a script from being saved if it has a syntax error to prevent this from even happening.

For those Dashboard scripts running well enough to get pass that issue; if I use Wait-Debugger to trigger a breakpoint, Enter-PSHostProcess of the relevant process and use Debug-Runspace on the runspace with the breakpoint, I will often get no output or shell, making the breakpoint useless.

I don’t use this typically. I will occasionally use the built in PSU debugger console but I would like to improve this experience. It’s really hard to see what’s happening within the dashboard scripts. I have noticed differences between Windows PowerShell and PowerShell 7 when using VS Code for remote debugging like this (not necessarily PSU). I end up with a lot of Write-Information or Show-UDToast in my scripts to expose info from dashboard endpoints.

I’ve built and rebuilt a couple debugging tools in PSU but nothing I’ve felt actually solves this issue.

I also notice if I restart a Dashboard script often enough, it will eventually have some sort of silent issue where it will no longer start properly (despite saying it’s “Started”), acting as if no Cmdlets are being run at all. The only way to fix this is to restart the PowerShellUniversal Windows Service.

I’ve seen this issue when I have a syntax error in the dashboard. I typically will have to click Stop, even though it seems like it isn’t running, and then Start again to get it to go but don’t have to restart the entire server. I wonder if this is related to your first issue where it seems like everything stops working.

No error information, unreliable breakpoints and a finite limit to how many dashboard restarts in one lifespan of the PSU service… does anyone else have these issues? How are other people debugging their dashboards during development? How can I begin to troubleshooting some of these issues?

A couple questions:

What environment are you running your dashboards in? If integrated, I would recommend an external process to isolate the issue and easily enable restarting the process.

How long does it take before you start experiencing all these issues (breakpoints aside)? Minutes\hours?

I typically use VS Code remotely when working with my dev PSU instance, which is remote for me. Initially I tried exclusively with editing files through the PSU VS Code Extension but sometimes, it would stop tracking my local changes of the temporary copy and stop uploading it so I just mount the remote file system and edit the files that way. Maybe I should give the proper way another chance.

This is what I sometimes do as well but, you must admit, this is tedious compared to a modern debugging experience and is difficult to use if you need to examine complex data structure.

Yes, it seems to typically occur after syntax errors as well but, even after I fixed them and try using ‘Stop’, it will sometimes not start again until I restart the PSU server.

Windows Server 2019 and PowerShell 7 as an external process, I’m often using my own .NET libraries so I try not to pollute the Universal process with them. It’s also easier when it’s an external process if something malfunctions as I can easily kill it and it’s also easier to target with Enter-PSHostProcess.

Probably an hour or two, after a few dozen restarts.

I think overall, it seems we develop dashboards differently. I try to stay within the VS Code environment as often as possible and don’t use the in-built editors in PSU, although I do use the Advanced Editor when I’m experimenting with UD stuff I haven’t worked with before but not for my bigger dashboard projects.