You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
In the current Pode implementation, the following block of code attempts to invoke Write-PodeErrorLog inside a catch block if an exception occurs:
try {
if (! (Test-PodeIsISEHost)) {
if (!$ctx.Server.Console.Quiet) {
[System.Console]::CursorVisible =$falseif ($ctx.Server.Console.ShowDivider) {
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
}
}
if (Test-PodeIsConsoleHost) {
[Console]::TreatControlCAsInput =$true
}
}
}
catch {
$_|Write-PodeErrorLog$ctx.Server.Console.DisableTermination=$true$ctx.Server.Console.DisableConsoleInput=$true$ctx.Server.Console.Quiet=$true$ctx.Server.Console.ShowDivider=$false
}
However, Write-PodeErrorLog is being called before the logging subsystem is fully initialized. This creates compatibility issues with the new logging features introduced in PR [#1387](#1387).
Expected Behavior
The console initialization logic should handle errors gracefully without invoking Write-PodeErrorLog prematurely.
The context should be configured for non-console behavior in case of failure, without relying on logging at this stage.
Proposed Fix
A simple fix is to check if the session is running in a console and is not marked as a daemon before proceeding. Additionally, we should remove Write-PodeErrorLog from this section:
# Check if the current session is running in a console-like environment and it's not marked as Daemonif (Test-PodeHasConsole-and!$Daemon) {
try {
if (! (Test-PodeIsISEHost)) {
if (!$ctx.Server.Console.Quiet) {
[System.Console]::CursorVisible =$falseif ($ctx.Server.Console.ShowDivider) {
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
}
}
if (Test-PodeIsConsoleHost) {
[Console]::TreatControlCAsInput =$true
}
}
}
catch {
$ctx.Server.Console.DisableTermination=$true$ctx.Server.Console.DisableConsoleInput=$true$ctx.Server.Console.Quiet=$true$ctx.Server.Console.ShowDivider=$false
}
}
Steps to Reproduce
Start Pode in a separated pwsh in background
An exception is trigegred in the try block.
Observe that Write-PodeErrorLog is invoked before the logging subsystem is initialized.
Additional Notes
Removing Write-PodeErrorLog from this specific section should prevent any early logging issues while ensuring the console context is handled correctly.
The text was updated successfully, but these errors were encountered:
Description:
In the current Pode implementation, the following block of code attempts to invoke
Write-PodeErrorLog
inside acatch
block if an exception occurs:However,
Write-PodeErrorLog
is being called before the logging subsystem is fully initialized. This creates compatibility issues with the new logging features introduced in PR [#1387](#1387).Expected Behavior
Write-PodeErrorLog
prematurely.Proposed Fix
A simple fix is to check if the session is running in a console and is not marked as a daemon before proceeding. Additionally, we should remove
Write-PodeErrorLog
from this section:Steps to Reproduce
try
block.Write-PodeErrorLog
is invoked before the logging subsystem is initialized.Additional Notes
Removing
Write-PodeErrorLog
from this specific section should prevent any early logging issues while ensuring the console context is handled correctly.The text was updated successfully, but these errors were encountered: