You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Integrated console hangs if PSReadline sets AddToHistoryHandler #2246
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
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.
James O'Neill (@jhoneill) thanks for opening this and providing detailed information, we were able to reproduce this issue and will investigate the root cause...thanks!
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.
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, Dongbo Wang (@daxian-dbw) might have a better idea here.
James O'Neill (@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 :)
Andy Jordan (@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.
Activity
SydneyhSmith commentedon Oct 22, 2019
James O'Neill (@jhoneill) thanks for opening this and providing detailed information, we were able to reproduce this issue and will investigate the root cause...thanks!
corbob commentedon Oct 23, 2019
FWIW: Building both PSES and vscode-powershell from source based on the master branch doesn't appear to have this issue.
rjmholt commentedon 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 commentedon Jan 31, 2020
Thinking about this, we may need to override
Set-PSReadLineOptionto 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, Dongbo Wang (@daxian-dbw) might have a better idea here.
daxian-dbw commentedon Jan 31, 2020
James O'Neill (@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 commentedon Apr 12, 2022
Hey James O'Neill (@jhoneill), we just released v2022.4.0-preview! Could you please try PowerShell Preview for VS Code and verify this is fixed?
jhoneill commentedon Apr 13, 2022
Andy Jordan (@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.