-
Notifications
You must be signed in to change notification settings - Fork 498
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
Formatting PowerShell document during execution? #1562
Comments
The script is running now 2nd hour and I've been doing some edits on it
Now the question is if that process should be suspended or maybe running separate to the one running the script and so the running script could be refactored further while the one is running? |
Now the same problem touches multiple other issues. If the script is running |
When finally unlocked...
So only some executed. Sorry that I pasted it as multiple logs. |
Wow, I'm surprised that actually finished in the end. It sounds like there are a few things we should be doing to handle formatting better. Ultimately, the formatting itself is done by PSScriptAnalyzer. But we should probably put some delays, cancellations, etc. in there to make it nicer. |
Tagging @tylerl0706 and @SeeminglyScience for visibility. |
Please notice |
Do completions or the integrated terminal work? |
Yeah so it looks like the underlying session is effectively dead. Does it come back when the formatting finally finishes? |
Yes. It seems it's working on the same session as the script. If script is executed any action within VS Code is paused. Which makes developing "long" running scripts a bit harder ;-) And those are 2-3 minutes on my dev machine, but I've some running for hours like asking O365 for data. |
To be completely fair ISE also pauses things I believe. |
Yeah, most language features require being in the pipeline thread. If something is currently running there, the queue will just build up until it's finished. In 2.0 we could take over the thread via PowerShell's eventing system, but we could only take over between sequence points. If something in .NET was blocking, it would still be frozen until it finishes. (Also, that's not currently implemented for taking over anything other than PSRL, but it's something we should consider) |
Do we have a way to "send Ctrl+C" or some other SIGINT-style thing to the command executing in the pipeline? Otherwise, I'm not entirely sure what we can do to stop a long-running formatter |
Actually formatting/PSSA in general is one of the few things that do not need the pipeline thread (at least, not the main pipeline). That bit is more likely due to the fact that we currently only handle one language service request at a time. |
In this instance I don't think it's the formatter that is running for a long time. I believe it's just that the formatter isn't really starting until the script is over. We can request a stop though, with |
I just had this case where I would run this script
Run it.. added one little Select-Object and pressed F5 (or save and f5) by accident
and I would see formatting powershell suddenly going nuts
After it came back F5 doesn't work anymore. It doesn't display any message either 1539173542-fa293ce8-7d4d-4c82-acd6-50ff768550271539173534901.zip I restarted powershell and it came back 1539173542-fa293ce8-7d4d-4c82-acd6-50ff768550271539173534901.zip 2nd log is taken after restart of powershell (I guess it contains a bit more information on what happend). Not sure if it's related to this one or you want another ticket |
Ok, in the immediate I think we should introduce a timeout on formatting like we have script analysis. I think the deeper issue is a common one we have with the async context, which will require a fair amount of careful work. |
@rjmholt I think I'm misunderstanding something about this issue in particular. To me it looks like VSCode is reporting that it is starting formatting before we PSES even gets the message, and the time it takes is not the formatter, but waiting for the existing |
@SeeminglyScience since I haven't looked very closely at the actual implementation, I'm thinking your interpretation is probably the best one. But either way, a timeout on formatting feels like the best way to stop the formatter going wild here, no? |
I'm getting this more and more lately.
Not really sure why. I can just start a project (open VSCode and new folder with few files and see it happen). Not sure why thou. And I am not exactly sure if terminating formatting would fix this. As the formatting part actually in this "smaller" case finishes 3.09s (still a lot). But then I can't run anything. In this case restarting powershell helps out. I do have logs from this if required. |
System Details
System Details Output
Issue Description
I run a script. During running of the script I edit some stuff and press Save. It does format on save (as designed) but it seems it queue it for later...
Now if i continue edits it will queue it more and more..
Attached Logs
As you can see the script is running I press Save on multiple times and it seems to be starting reformat and reformat again and again. My guess is that when it's done it will do 4 times reformat right? Maybe it should disable that feature when script is running since it's not doing anything?
The text was updated successfully, but these errors were encountered: