Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception setting "RunspacePool" in 1.6.0.0 build #82

Closed
replicaJunction opened this issue Aug 12, 2016 · 6 comments
Closed

Exception setting "RunspacePool" in 1.6.0.0 build #82

replicaJunction opened this issue Aug 12, 2016 · 6 comments
Assignees
Labels
Milestone

Comments

@replicaJunction
Copy link

In the latest build, Start-RsJob gives me the following error each time it runs except for the first time:

Exception setting "RunspacePool": "Object reference not set to an instance of an object."
At E:\MyProject\Modules\PoshRsJob\Public\Start-RSJob.ps1:463 char:17
+                 $PowerShell.RunspacePool = $RunspacePool
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting

I can't share the production code causing this, but here is a sample case that causes the same error:

[CmdletBinding()]
param()

# Not relevant to this sample, just illustrating that I'm using these params
$Throttle = 5
$modules = 'PSSqlite'

foreach ($i in 1..100) {
    Start-RsJob -Batch 'MyProject' -ModulesToImport $modules -Throttle $Throttle -Verbose:$VerbosePreference -Debug:$DebugPreference -ScriptBlock {
        [PSCustomObject] @{
            One = 1
            Two = 2
            Value = $using:i
        }
    }
}

Wait-RsJob -ShowProgress | Receive-RsJob | Write-Output
Get-RsJob | Remove-RsJob

Each run after the first causes the same exception.

I'm on Server 2008R2, PowerShell 4.0. This project works fine on the previous release of the module (1.5.7.7). Let me know if I can do any additional troubleshooting to assist!

@proxb
Copy link
Owner

proxb commented Aug 12, 2016

Thanks for the heads up! I'm going to dig in and see where this is failing at. Just curious, is this running in a script or function or is this failing when you run this 'as is' such as in the ISE?

@proxb proxb added the question label Aug 13, 2016
@proxb proxb self-assigned this Aug 13, 2016
@proxb
Copy link
Owner

proxb commented Aug 13, 2016

I'm in the process of building a VM to mirror the OS and PowerShell version so I can test it properly

@proxb
Copy link
Owner

proxb commented Aug 15, 2016

Ok, it looks like the runspacepool work that I did is causing the issue. I'm going to dig into this and figure out a good fix.

@proxb
Copy link
Owner

proxb commented Aug 15, 2016

I found the issue and am working on publishing an update to the module.

proxb added a commit that referenced this issue Aug 15, 2016
Fix issue #82
@proxb
Copy link
Owner

proxb commented Aug 15, 2016

@replicaJunction Try the latest version and let me know how it works.

@proxb proxb added this to the 1.6.1.0 milestone Aug 15, 2016
@replicaJunction
Copy link
Author

Apologies for the delayed response - I didn't see your question until just now. It was failing when run as a standalone .ps1 file, but I guess that's not relevant since you found the issue.

The latest build runs with no problems. Thanks very much!

@proxb proxb closed this as completed Aug 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants