Skip to content

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

@DarkLite1

Description

@DarkLite1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions