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.

PSReadLine Errors cause prompt to loop endlessly

See original GitHub issue

Environment data

PSReadline version: 2.0.0-beta4
os: Darwin Robbies-MBP 18.5.0 Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64 x86_64
PS file version: (the script sample didn't work, mac doesn't have a .exe)

Major  Minor  Patch  PreReleaseLabel BuildLabel
-----  -----  -----  --------------- ----------
6      2      0      preview.4       

Steps to reproduce or exception report

Enter the VS Code debugger, run a cmdlet in a module and have it stop at a breakpoint, then select the menu option Debug->Stop Debugging. Then PSReadline/Powershell goes into an endless loop displaying the following error:

Exception

System.Management.Automation.Runspaces.InvalidRunspaceStateException: Cannot invoke the pipeline because the runspace is not in the Opened state. Current state of the runspace is 'Closing'.
   at System.Management.Automation.Runspaces.RunspaceBase.AddToRunningPipelineList(PipelineBase pipeline)
   at System.Management.Automation.Runspaces.RunspaceBase.DoConcurrentCheckAndAddToRunningPipelines(PipelineBase pipeline, Boolean syncCall)
   at System.Management.Automation.Runspaces.PipelineBase.CoreInvoke(IEnumerable input, Boolean syncCall)
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at System.Management.Automation.Runspaces.Pipeline.Invoke()
   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.Invoke()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadKey()
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken)

P> @
Oops, something went wrong. Please report this bug with the details below. Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new

Environment

PSReadLine: 2.0.0-beta3 PowerShell: 2.0.0 OS: Darwin 18.2.0 Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST 2018; root:xnu-4903.241.1~1/RELEASE_X86_64 Last 200 Keys

 o r t - d u Backspace Backspace m o d u l e Spacebar d u a c c o u n t m a n a g e m e n t Spacebar - f o r c e Enter
 UpArrow UpArrow UpArrow UpArrow Enter
 UpArrow UpArrow Enter
 UpArrow UpArrow Enter
 $ t Enter
 $ t . t e n Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace i m p o r t m Backspace - m o d u l e Spacebar d u a c c o u n t n a Backspace Backspace m a n a t e m e n g Backspace Backspace Backspace Backspace Backspace Backspace g e m e n t Spacebar - f o r c e Enter
 g e t - d u u s e r Tab Spacebar r f o u s t Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 c Enter
 Ctrl+c @

Exception

System.Management.Automation.Runspaces.InvalidRunspaceStateException: Cannot invoke the pipeline because the runspace is not in the Opened state. Current state of the runspace is 'Closing'.
   at System.Management.Automation.Runspaces.RunspaceBase.AddToRunningPipelineList(PipelineBase pipeline)
   at System.Management.Automation.Runspaces.RunspaceBase.DoConcurrentCheckAndAddToRunningPipelines(PipelineBase pipeline, Boolean syncCall)
   at System.Management.Automation.Runspaces.PipelineBase.CoreInvoke(IEnumerable input, Boolean syncCall)
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at System.Management.Automation.Runspaces.Pipeline.Invoke()
   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.Invoke()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadKey()
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken)

P> @

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
TylerLeonhardtcommented, Dec 20, 2019

@rfoust Can you give this a go in the newer versions of the PowerShell Preview extension? It has a ton of fixes in it and it might be fixed in that already.

0reactions
andschwacommented, Aug 19, 2021

I know the bot auto-closed this due to age, but reading through the original issue, it may very well be fixed by the latest preview (going out today). I threaded through a cancellation token so that the debugger can stop more gracefully.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PSReadLine Errors cause prompt to loop endlessly #2381
FYI, this is just what it looks like whenever PSES crashes with PSRL. The runspace is closed during shutdown, but PSRL isn't properly...
Read more >
PowerShell Looping: Understanding and Using Do…Until
If a condition never becomes True, the script goes into an endless loop. In my example, 9 is never less than or equal...
Read more >
The specified module 'Module Name' was not loaded because ...
Problem: When trying to import the PnP PowerShell module, I got an error message “Import-Module: The specified module 'SharePointPnPPowerShellOnline' was ...
Read more >
Bounce back loop from 'Email-to-Case' creates more than ...
Scenario: If a customer has the 'Email To Case' process setup with an auto-response rule they may run into instances where the system...
Read more >
Intentional Infinite Loops - Incremental Java
Incremental Java Infinite Loops. What is an Infinite Loop? An infinite loop occurs when a condition always evaluates to true. Usually, this is...
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