question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debugger won't run until `ENTER` is pressed in integrated console

See original GitHub issue

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.

Summary

This is currently only happening with v2021.8.1-preview (the PowerShell Preview extension) and PowerShell 7, but it happens on Windows and macOS. @SeeminglyScience confirmed for me: run any PowerShell script in the debugger, it won’t actually do anything (like run to a breakpoint or completion) until you manually go to the integrated console and press ENTER.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.1.4
PSEdition                      Core
GitCommitId                    7.1.4
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.59.1
3866c3553be8b268c8a7f8c0482c0c0177aa8bfa
x64

Extension Version

ms-vscode.powershell-preview@2021.8.1

Steps to Reproduce

  1. Run PowerShell script in debugger
  2. It hangs until ENTER is sent

Visuals

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
andschwacommented, Aug 20, 2021

Haha, oops, our bad. @rjmholt and I added the Stop() registration at the last minute. That explains why this was only in 2.4.8 and not 2.4.7.

1reaction
SeeminglySciencecommented, Aug 20, 2021

@andschwa I think it’s this:

https://github.com/PowerShell/PowerShellEditorServices/blob/6a19daf5bc3e8547fbdc10f351ac2a81d76f9cec/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs#L768

        public async Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
            PSCommand psCommand,
            StringBuilder errorMessages,
            ExecutionOptions executionOptions,
            CancellationToken cancellationToken = default)
        {
            // (...)
            cancellationToken.Register(() => shell.Stop());

Linked cancellation token sources work by essentially registering a cancellation handler on the target token. I’m guessing the handlers are invoked sequentially on the same thread, and if that’s the case then the link handler will never fire because shell.Stop won’t finish. The pipeline won’t stop until ReadLine returns, and ReadLine won’t return until the next cancel handler fires.

Might get away with just changing it to shell.BeginStop()

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCode - cannot enter input into console while debugging C++
I am trying to debug a single C++ file on Visual Studio Code on Windows. Running and debugging works fine. However, when I...
Read more >
Not able to capture user input on internal terminal when ...
Now debug any java file which accepts user inputs. VS Terminal won't be able to capture those inputs. Note: External console i.e. cmd...
Read more >
Debugging in Visual Studio Code
To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and...
Read more >
Code Running Assistance | PyCharm Documentation - JetBrains
Each script or test you wish to run or debug from within PyCharm, needs a special profile that specifies the script name, working...
Read more >
Debugging in the browser - The Modern JavaScript Tutorial
Console. If we press Esc , then a console opens below. We can type commands there and press Enter to execute. After a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found