-
-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: How to actually debug ? #467
Comments
Hey @ArieHein, If you're using the internal Pode restarts, then this page might help - when the server restarts, the main scriptblock supplied to For minimal components, it depends on the server type; but if we assume a web-server then mostly just an I know what you mean about the debugging and route scriptblocks, runspaces are quite a pain for this. Normally when I need to debug something in these I go down the simple road of It'd be nice if breakpointing for runspaces did work, but at the moment I'm unaware if there's a way to make it possible 😕 |
Yes i do use the restart via filewatcher, im more refering to debugging inside the script block. |
I think I understand what you're after, but would you be able to give a rough code example as to what you need? For the variable content the closest I can think of is |
Assume this for server.ps1
Assume this is General.psm1
So basically, a request comes to /general and the script block runs the Get-GeneralData function from the module that returns something. When i change the internal code of the module it has no effect on the server successfully coming up or not ,as it should but i loose the ability to debug the changes in the module and im looking for a way to push some values back to terminal or otherwise that will allow me some sort of looking at values while its in the module. If the Catch inside the module throws the exception, its not that the call from pode failed so pode will see this as successful. Hope that made it more visible. |
I think I can see what you're getting at. If it's just outputting values back to the terminal wouldn't using It might also be worth investigating |
Hmm, what is out-PodeHost ? |
|
Hey @Badgerati! Have you had any success with Debug-Runspace? I tried it earlier but didn't get far. I'm hoping to be able to set a breakpoint or attach a debugger at a specific point in a scriptblock so I can check the state. |
@fatherofinvention I do this https://github.com/ili101/PWT/blob/main/DebugHelper.ps1
|
@ili101 Wow... this is brilliant. It works perfectly. You seriously just leveled up my productivity with this. Thank you! Tagging @Badgerati for visibility. |
@ili101 @fatherofinvention awesome! I played with I'll have a try myself too, and update the docs with a debugging section; also wondering if there's any helper functions I can put into Pode to for this as well 🤔 |
Re-opening this to update the docs with debugging notes. |
Here is some peculiar but surprisingly robust bare runspace debugger: In your Pode route handler or similar code call When breakpoints are hit, enter debugger commands as prompted (either in console or GUI depending on the host and Trivial example: add the debugger and break immediately after: Add-Debugger
Wait-Debugger Tip: Use |
@nightroman - Fan of your work, been following you on Github for years. Thanks for sharing this here, I'll give it a try later today. |
@nightroman just came back to say thank you once more for Add-Debugger. It's a game changer for debugging Pode. For anyone new to it, it installs as a Script and not a Module which means you'll need to make sure your scripts directory is in your PATH if it isn't already. You can add it on Ubuntu for example like this:
You should see it there now when you run @Badgerati wondering if you've given this a shot yet? I think it will really speed up your work on Pode too ! |
One last tip: if you run |
@fatherofinvention I have given it a shot, and it's really useful when any error aren't immediately obvious :) I've documented it use now as well in 2.9.0 |
Question
When I'm doing changes in my server.ps1 and i relaunch my server, it goes up correctly but some of the changes i do do not appear to work but i have no way of knowing what is going underneath. Is there like a best practice guide for the minimum components in server.ps1 that need to be up for this to happen ?
I know how to use logging to track requests, but I'm looking into the debugging of the inner Script blocks, its not like i can put breakpoints into server.ps1
The text was updated successfully, but these errors were encountered: