Skip to content
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

Integrated console hangs if PSReadline sets AddToHistoryHandler #2246

Closed
jhoneill opened this issue Oct 20, 2019 · 7 comments
Closed

Integrated console hangs if PSReadline sets AddToHistoryHandler #2246

jhoneill opened this issue Oct 20, 2019 · 7 comments
Labels
Area-PSReadLine Issue-Bug A bug to squash. Needs: Fix Verification Please verify the fix for us!

Comments

@jhoneill
Copy link

I'm running preview but I think this may be in the release as well.
psreadline can save your passwords to its plaintext log. To prevent this leeholmes put out a little fragment

        Set-PSReadLineOption -AddToHistoryHandler {
            param([string]$line)
            $sensitive = "password|asplaintext|token|key|secret"
            return ($line -notmatch $sensitive)
        }

I found this was hanging my Intergrated console (but not a PowerShell terminal) in VS Code.

easy to repro
ensure you have the integrated console selected.
Run a command.
paste in
Set-PSReadLineOption -AddToHistoryHandler {param([string]$line) return $true}
Re-run the previous command

This may be a psreadline bug but it only occurs in the integrated console.

@ghost ghost added the Needs: Triage Maintainer attention needed! label Oct 20, 2019
@SydneyhSmith
Copy link
Collaborator

@jhoneill thanks for opening this and providing detailed information, we were able to reproduce this issue and will investigate the root cause...thanks!

@SydneyhSmith SydneyhSmith added Area-PSReadLine Issue-Bug A bug to squash. and removed Needs: Triage Maintainer attention needed! labels Oct 22, 2019
@corbob
Copy link
Contributor

corbob commented Oct 23, 2019

FWIW: Building both PSES and vscode-powershell from source based on the master branch doesn't appear to have this issue.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Oct 23, 2019
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Oct 23, 2019
@rjmholt
Copy link
Contributor

rjmholt commented Oct 24, 2019

It's probably non-deterministic, but the issue lies with trying to make PSReadLine work in a world where the prompt doesn't stop processing. The fix will lie in ensuring the scriptblock is run on the pipeline thread.

@rjmholt
Copy link
Contributor

rjmholt commented Jan 31, 2020

Thinking about this, we may need to override Set-PSReadLineOption to intercept parameters that run scriptblocks and turn them into callbacks back into PSES to run things on the pipeline thread.

However that's rather complex, so I'm not going to attempt it immediately. Also, @daxian-dbw might have a better idea here.

@daxian-dbw
Copy link
Member

@jhoneill I'm not sure about what causes the deadlock, but maybe a good news is that with the latest version of PSReadLine, you don't need leeholmes workaround to filter out the sensitive commands, it's built-in now :)

@andyleejordan
Copy link
Member

Hey @jhoneill, we just released v2022.4.0-preview! Could you please try PowerShell Preview for VS Code and verify this is fixed?

@andyleejordan andyleejordan added the Needs: Fix Verification Please verify the fix for us! label Apr 12, 2022
@jhoneill
Copy link
Author

@andschwa In the current version this problem has gone away. Obvious it's been around for a while and I haven't kept checking it so I can't say if it was a recent change that fixed it but this can be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-PSReadLine Issue-Bug A bug to squash. Needs: Fix Verification Please verify the fix for us!
Projects
None yet
Development

No branches or pull requests

6 participants