Skip to content

Integrated console hangs if PSReadline sets AddToHistoryHandler #2246

Closed

Description

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.

Activity

  1. ghost added
    Needs: Triage
    on Oct 20, 2019
  2. SydneyhSmith commented on Oct 22, 2019

    @SydneyhSmith
    Collaborator

    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!

  3. added
    Issue-Bug
    and removed
    Needs: Triage
    on Oct 22, 2019
  4. corbob commented on Oct 23, 2019

    @corbob
    Contributor

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

  5. ghost added
    Needs: Maintainer Attention
    on Oct 23, 2019
  6. rjmholt commented on Oct 24, 2019

    @rjmholt
    Contributor

    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.

  7. rjmholt commented on Jan 31, 2020

    @rjmholt
    Contributor

    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.

  8. daxian-dbw commented on Jan 31, 2020

    @daxian-dbw
    Member

    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 :)

  9. ghost added
    Needs: Maintainer Attention
    on Jan 31, 2020
  10. andyleejordan commented on Apr 12, 2022

    @andyleejordan
    Member

    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?

  11. jhoneill commented on Apr 13, 2022

    @jhoneill
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-PSReadLineIssue-BugNeeds: Fix Verification

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions