-
Notifications
You must be signed in to change notification settings - Fork 508
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
Using PowerShell Preview v2021.11.1, PSReadLine throws an error every so often #3701
Comments
@andschwa can you please take a look? |
@daxian-dbw Transferred, will look into. |
@energetic-it Can you give me more information on how to reproduce this? |
@daxian-dbw I think maybe our
Clearly there's some race happening. My current guess I'd want to investigate if I can reproduce this is that this hacky section of code: // We didn't end up executing anything in the background,
// so we need to run a small artificial pipeline instead
// to force event processing
if (runPipelineForEventProcessing)
{
InvokePSCommand(new PSCommand().AddScript("0", useLocalScope: true), PowerShellExecutionOptions.Default, CancellationToken.None);
} Isn't locked and therefore it's running its fake task after other stuff started running. |
Adding comment to follow... First mentioned here: PowerShell/PSReadLine#3091 I have this consistently. Let me know if there is anything I can provide in the way of logs etc ? $PSVersionTable
Name Value
---- -----
PSVersion 7.3.0-preview.1
PSEdition Core
GitCommitId 7.3.0-preview.1
OS Microsoft Windows 10.0.22526
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
gmo psreadline
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.2.0 beta4 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler…}
code-insiders --list-extensions --show-versions
ms-vscode.powershell-preview@2021.12.0
|
What can I do to help out? |
@andschwa For that to run, there needs to be event subscribers registered. |
Good call, I do.. as below, thank you so much 😊 Get-EventSubscriber -Force | foreach action | foreach command
if ([Microsoft.Azure.PowerShell.Tools.AzPredictor.AzPredictorData]::ShowSurveyOnIdle) {
[Microsoft.Azure.PowerShell.Tools.AzPredictor.AzPredictorData]::ShowSurveyOnIdle = $False
Write-Host ''
Write-Host ''; Write-Host `Survey: -ForegroundColor $Host.PrivateData.VerboseBackgroundColor -BackgroundColor $host.PrivateData.VerboseForegroundColor -NoNewLine; Write-Host ' How was your experience using the Az Predictor module?'
Write-Host ''
Write-Host 'Run ' -NoNewline; Write-Host Open-AzPredictorSurvey -ForegroundColor $Host.PrivateData.VerboseBackgroundColor -BackgroundColor $host.PrivateData.VerboseForegroundColor -NoNewline; Write-Host ' to give us your feedback.'
Write-Host ''
Write-Host '(Use "Ctrl + C" to return to the prompt)'
} Thank you so much.... As it turns out I actually have a separate issue open to remove that functionality, so I believe it will be going away in the next release as per this thread. I will follow up over there in regards to this, thanks again, really appreciate the support. |
@brwilkinson I believe that event handler comes from the Az.Tools.Predictor. Is this particular exception gone after you remove that module or start PowerShell without auto-load that module? |
makes sense for sure, thank you. I added to the following if ( $PSVersionTable.psversion.Major -ge 7 -and $PSVersionTable.PSVersion.Minor -ge 2)
{
Enable-AzPredictor
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
Get-EventSubscriber -Force -SourceIdentifier PowerShell.OnIdle -EA 0 | Unregister-Event -Force
} |
I am so thankful Dongbo, that you were able to discover this... 🙏🏼👍🏼 I haven't any occurrences after unregistering the event subscriber, straight after loading the azPredictor module. |
I had the same EventSubscriber, the workaround Ben posted works for me as well. |
Ah ha! Glad we've figured this out. Now, we certainly shouldn't be crashing due to events, so there is clearly a bug we can solve here, and looks like we have the info we now need to reproduce this. Thanks all! |
@andschwa The fix will be tricky. Please take a look at my comment about the problem: PowerShell/PSReadLine#1679 (comment) We have PowerShell/PowerShellEditorServices#1591 tracking the issue. |
@SydneyhSmith we know what the root cause is here, and the workaround is to unregister the events. Since we don't have a timeline for a true bug fix (as that would require a patch to PowerShell itself), we need to determine the best mitigation strategy:
|
There may already work being done on this.
@dcaro or @kceiw did you happen to have any status update on the above? Perhaps we can figure out a timeline?
|
This is in progress as an Azure PowerShell dev and I have been working on conditionally disabling their event registration so this bug does not show up in the extension. There isn't a good solution, but at least we have a workaround. |
@SydneyhSmith We're waiting for Azure PowerShell to release v7.2.1 which should contain the referenced fix (is that correct @VeryEarly?), and then we'll have at least worked around the most prevalent cause of this issue. |
Az.Tools.Predictor 1.0 GA'd and should no longer be one of the causes of this issue. Probably other cases that might trigger this so not entirely fixed. There is work arounds linked above |
This issue has been marked as external. It has been automatically closed for housekeeping purposes. |
Prerequisites
Exception report
Screenshot
Environment data
Steps to reproduce
On my system.
Starting VSCode, using the Windows Store Powershell or Powershell preview installation.
Using the PowerShell Preview v2021.11.1 extension.
Without doing anything the error provided will pop up every now and then. (writing this generated 5 errors already)
Just having the
It breaks any running scripts I have going.
Using the normal PowerShell extension everything works fine.
Expected behavior
No PSreadline errors while using the PowerShell Preview v2021.11.1 extension.
Actual behavior
I'm unable to use the PowerShell Preview v2021.11.1 extension because of this PSReadline error happening a couple of time every few minute.
The text was updated successfully, but these errors were encountered: