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

Runspace error on pode start #1137

Closed
v2kiran opened this issue Sep 21, 2023 · 6 comments · Fixed by #1147
Closed

Runspace error on pode start #1137

v2kiran opened this issue Sep 21, 2023 · 6 comments · Fixed by #1147
Assignees
Labels
Milestone

Comments

@v2kiran
Copy link

v2kiran commented Sep 21, 2023

Describe the Bug

Failed to close RunspacePool: Main error on running pode start

Steps To Reproduce

Steps to reproduce the behavior:
create a simple server.ps1 witht he following content:

Start-PodeServer {
    New-PodeLoggingMethod -Terminal | Enable-PodeErrorLogging
    Write-Host 'hello, world!'
}

run pode start

Expected Behavior

hello world is print with no error

Screenshots

image

Platform

  • Windows
  • Chrome,edge,firefox
  • Versions:
    • Pode 2.8.0
    • Pwsh 7.3.6

Additional Context

Also tried with an older version of pode, tried another user account, different content in server.ps1

@v2kiran
Copy link
Author

v2kiran commented Sep 23, 2023

did some debugging and found there is a conflict with another module called "completionpredictor".
I removed completionpredictor from the session and the error went away.

this is what i found during debugging:

Exception: C:\Users\Kiran\OneDrive\Documents\PowerShell\Modules\Pode\2.7.2\Private\Context.ps1:714:13
Line |
 714 |              $item.Pool.EndOpen($item.Result) | Out-Default
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "EndOpen" with "1" argument(s): "The implementation with Id '77bb0bd8-2d8b-4210-ad14-79fb91a75eab' was already registered for the
     | subsystem 'CommandPredictor'."

``

@Badgerati
Copy link
Owner

Hi @v2kiran,

The first error appears to be when closing the runspace, while the second error seems to be while trying to open the runspace. Do you know if they're both related to the CommandPredictor module?

If you try disabling the auto-importing of modules, does that resolve the issue? (https://badgerati.github.io/Pode/Tutorials/Scoping/#disable)

@v2kiran
Copy link
Author

v2kiran commented Sep 26, 2023

hi @Badgerati - thanks for replying.
I just ran "remove-module completionpredictor". then pode ran.

I then changed the server.ps1 script slightly then ran into another error about importing modules after which i basically gave up.

{
    # attach to port 8080 for http
    Add-PodeEndpoint -Address localhost -Port 8085 -Protocol Http

    # a simple page for displaying services
    Add-PodePage -Name 'processes' -ScriptBlock { Get-Process }
}

i also have this psd1 file named server.psd1 in the same directory but didnt change do anything:

@{
    Server = @{
        AutoImport = @{
            Modules = @{
                Enable = $false
            }
        }
    }
}
Import-Module: C:\Users\Kiran\OneDrive\Documents\PowerShell\Modules\Pode\2.8.0\Private\Helpers.ps1:933:17
Line |
 933 |       $null = Import-Module $path -DisableNameChecking -Scope Global -E 
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The specified module 'C:\gh\learn-pode\31a63532-6abc-443a-8533-7462fe8fe31f' was not loaded because no valid module file was found in any module
     | directory.

at Import-PodeModules, C:\Users\Kiran\OneDrive\Documents\PowerShell\Modules\Pode\2.8.0\Private\Helpers.ps1: line 933
at Open-PodeRunspace, C:\Users\Kiran\OneDrive\Documents\PowerShell\Modules\Pode\2.8.0\Private\Helpers.ps1: line 603
at <ScriptBlock>, <No file>: line 1

Import-Module: C:\Users\Kiran\OneDrive\Documents\PowerShell\Modules\Pode\2.8.0\Private\Helpers.ps1:933:17
Line |
 933 |       $null = Import-Module $path -DisableNameChecking -Scope Global -E 
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The specified module 'C:\gh\learn-pode\31a63532-6abc-443a-8533-7462fe8fe31f' was not loaded because no valid module file was found in any module
     | directory.

at Import-PodeModules, C:\Users\Kiran\OneDrive\Documents\PowerShell\Modules\Pode\2.8.0\Private\Helpers.ps1: line 933
at Open-PodeRunspace, C:\Users\Kiran\OneDrive\Documents\PowerShell\Modules\Pode\2.8.0\Private\Helpers.ps1: line 603
at <ScriptBlock>, <No file>: line 1
ParentContainsErrorRecordException: C:\Users\Kiran\OneDrive\Documents\PowerShell\Modules\Pode\2.8.0\Private\Helpers.ps1:730:9
Line |
 730 |          throw $_.Exception
     |          ~~~~~~~~~~~~~~~~~~
     | Main runspace failed to load: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop:
     | The specified module 'C:\gh\learn-pode\31a63532-6abc-443a-8533-7462fe8fe31f' was not loaded because no valid module file was found in any module
     | directory.

@Badgerati
Copy link
Owner

Hi @v2kiran,

Well I just found a bug with Auto-Importing! Turns out the configuration is actually being ignored, so I'll get that fixed.

What's the module at C:\gh\learn-pode\31a63532-6abc-443a-8533-7462fe8fe31f it's trying to load? If it's extension is .ps1 changing it to .psm1 should work.

@Badgerati Badgerati added this to the 2.9.0 milestone Sep 27, 2023
@v2kiran
Copy link
Author

v2kiran commented Sep 28, 2023

thats great :)
31a63532-6abc-443a-8533-7462fe8fe31f - i have no clue what module it is trying to load because there are no files in the root directory .....basically trying a very simple example.

Note: this string (31a63532-6abc-443a-8533-7462fe8fe31f) changes everytime i restart the ps session..

@JustinGrote
Copy link

JustinGrote commented Oct 20, 2023

Just a quick bump as I have the same issue as @v2kiran on a fresh Win10 insider system, tried in both 5.1 and 7.3.8. I'll try to build the dev version and see if that fixes it.

EDIT: Didn't happen on a Win2012 server

@Badgerati Badgerati mentioned this issue Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants