Skip to content

RuntimeException: The script failed due to call depth overflow. #2174

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

Closed
DarkLite1 opened this issue May 9, 2022 · 4 comments
Closed

RuntimeException: The script failed due to call depth overflow. #2174

DarkLite1 opened this issue May 9, 2022 · 4 comments

Comments

@DarkLite1
Copy link
Contributor

General summary of the issue

This issue only happens in vscode and its terminal, not when executed from the normal Windows PowerShell Terminal application.

Describe your environment

host

Pester version     : 5.3.3 C:\Program Files\WindowsPowerShell\Modules\Pester\5.3.3\Pester.psm1
PowerShell version : 5.1.14393.5066
OS version         : Microsoft Windows NT 10.0.14393.0

vscode

Version: 1.67.0 (system setup)
Commit: 57fd6d0195bb9b9d1b49f6da5db789060795de47
Date: 2022-05-04T12:06:02.889Z
Electron: 17.4.1
Chromium: 98.0.4758.141
Node.js: 16.13.0
V8: 9.8.177.13-electron.0
OS: Windows_NT x64 10.0.14393

Steps to reproduce

Create the following two files:

# Pester.ps1
Param (
    [Parameter(Mandatory)]
    [String]$LogFolder
)

try {
    try {
        $params = @{
            Path        = $LogFolder 
            ItemType    = 'Directory' 
            Force       = $true
            ErrorAction = 'Stop'
        }
        $null = New-Item @params
    }
    Catch {
        throw "Failed creating the log folder '$LogFolder': $_"
    }
}
catch {
    Write-Output $_
}
# Pester.Tests.ps1
BeforeAll {
    $testScript = $PSCommandPath.Replace('.Tests.ps1', '.ps1')

    Mock Write-Output
}
Describe 'test should be' {
    It 'green' {
        .$testScript -LogFolder 'xxx:://notExistingLocation'

        Should -Invoke Write-Output -Exactly 1
    }
}

From a third file run this code from within vscode:

0..10 | ForEach-Object {
    Invoke-Pester '.\Pester\Pester.Tests.ps1' -Output Detailed
}

Expected Behavior

All single executed tests should be green

Current Behavior

The first 3 or 5 executions the results are as expected, green. However, after that the result is red and displays the error:

   ScriptCallDepthException: The script failed due to call depth overflow.
   RuntimeException: The script failed due to call depth overflow.

image

@fflaten
Copy link
Collaborator

fflaten commented May 9, 2022

Thanks for the report and sample. This is similar to #1974 and not sure how to fix tbh.

I've re-posted it in vscode-powershell as I'm only able to reproduce in vscode Integrated Console using PS5.1 engine. Looks like it's suffering from the limited call depth we've also seen with PS jobs/remoting.

@fflaten
Copy link
Collaborator

fflaten commented May 9, 2022

@nohwnd Tips? Just label this and #1974 as external bug for now?

@DarkLite1
Copy link
Contributor Author

Thanks for looking into this and I appreciate you opening a ticket with vscode-powershell. This is a bit of annoying issue as we can't use the vscode debugger to step through the code anymore unless it's the first time we run that code, on second run it always fails with this error. Our production code is way more complex and fails always on second attempt.

Hopefully they see where the issue is. Thx again for the quick help.

@fflaten
Copy link
Collaborator

fflaten commented May 22, 2022

Closing as this was fixed by @nohwnd in PowerShell/PowerShellEditorServices#1797. 🥳
Use latest vscode-powershell preview or wait for next stable extension release.

@fflaten fflaten closed this as completed May 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants