Skip to content

Removing Jobs created by Start-PSNode throws Busy Runspace errors #978

Open
@ninmonkey

Description

@ninmonkey

About

If you run a new node, and Stop-Job it works fine. You can run new instances.

But If you Remove-Job, starting a new node throws an error about runspace pool 1 not being open.

> get-runspace |ft -AutoSize
Id Name      ComputerName Type  State  Availability
-- ----      ------------ ----  -----  ------------
 1 Runspace1 localhost    Local Opened Busy
 3 Runspace3 localhost    Local Opened Available

To reproduce

# new tab using Pwsh -nop
Import-Module -pass 'c:\pwsh\PipeScript\PipeScript.psd1'
Start-PSNode -RootPath 'c:\foo\docs' -Command { get-date } -Server http://localhost:1234/ -AllowBrowseDirectory

Get-Job | Stop-Job
Get-Job | Remove-Job # skip this step and it runs fine

Start-PSNode -RootPath 'c:\foo\docs' -Command { get-date } -Server http://localhost:1234/ -AllowBrowseDirectory

Result

MethodInvocationException: c:\pwsh\PipeScript\Commands\Start-PSNode.ps1:329
Line |
 329 |              $psNodeJobInstance.Start()
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "Start" with "0" argument(s): "Cannot perform the operation because the runspace pool is not in the
     | 'Opened' state. The current state is 'Closed'."

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
5      80eea7d9-3abb-…                 Failed        False                                 get-date

Environment

pipescript: 0.2.8
branch: https://github.com/StartAutomating/PipeScript/tree/PipeScripting-Web
pwsh: 7.4.1

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions