-
-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Describe the Bug
Odd problem with New-PodeWebFileStream
I have a working work-around,
Steps To Reproduce
I have a form with only a checkbox and a submit button.
The form is used to start a log running task where the log output is streamed to the FileStream element.
If I do this:
New-PodeWebForm -Name "Run build" -Content @(
New-PodeWebCheckbox -Name 'Refresh' -DisplayName "Refresh MDA Entity"
) -ScriptBlock {
$Refresh = $WebEvent.Data['Refresh']
if ($Refresh) {
Update-PodeWebText -Id 'Job' -Value "MDA Refresh'"
Invoke-PodeTask -Name "EntityRefresh"
} else {
Update-PodeWebText -Id 'Job' -Value 'MDA Refresh'
Invoke-PodeTask -Name 'EntityBuild'
}
Start-Sleep 5 # Give the log time to build a bit
Restart-PodeWebFileStream -Name 'Stream'
}The task runs but the file stream does not stream the log file, it eventually times out, then the task completes, and the log contents show up in the filestream element. then I get a response error when the page completes. (in the error log)
If I do this:
New-PodeWebContainer -Content @(
New-PodeWebForm -Name "Run build" -Content @(
New-PodeWebHeader -Value "PBCS - MDA Build Entity" -Secondary "Click the Submit button to start the build process" -Size 2
New-PodeWebCheckbox -Name 'Refresh' -DisplayName "Refresh MDA Entity" @CheckBoxParams
) -ScriptBlock {
Move-PodeWebPage -Name '1ingestion' -DataValue $WebEvent.Data["Refresh"]
}
)
If ($WebEvent.Query['Value']) {
$Refresh = $WebEvent.Query['Value']
if ($Refresh) {
$task = Invoke-PodeTask -Name 'EntityRefresh'
} else {
$task = Invoke-PodeTask -Name 'EntityBuild'
}
New-PodeWebContainer -Content @(
#$Task = Get-PodeTask -name 'EntityBuild'
New-PodeWebText -Value $($Task.Name)
New-PodeWebFileStream -Name 'Stream' -Url $LogFile
)
}The page reloads, then the task runs and the log properly streams to the file stream element.
Expected Behavior
I would expect the proper method would be to execute the task in the forms script block and that restarting the filestream should start streaming the file. We should be able to put a file stream element on the page in a stopped state so that it does not try to stream a file that may not exist at the time the page is loaded. The when the file is being written to we can start the file stream.
Platform
- OS: Windows 10
- Browser: Chrome
- Versions:
- Pode: 2.12.0
- Pode.Web: 0.8.3
- PowerShell: 7.5
Additional Context
This is the error that happens when I try to execute the tasks in the Form script block.
Date: 2025-04-10 14:25:54
Level: Error
ThreadId: 1
Server: WSAMZN-SMPBI68A
Category: NotSpecified: (:) [ConvertTo-Json], InvalidOperationException
Message: Collection was modified; enumeration operation may not execute.
StackTrace: at Write-PodeJsonResponse, D:\Users\cwilliams\OneDrive - BALFOUR BEATTY\Documents\PowerShell\Modules\Pode\2.12.0\Public\Responses.ps1: line 796
at , : line 11
at Invoke-PodeScriptBlock, D:\Users\cwilliams\OneDrive - BALFOUR BEATTY\Documents\PowerShell\Modules\Pode\2.12.0\Public\Utilities.ps1: line 615
at , : line 126
Date: 2025-04-10 14:25:54
Level: Error
ThreadId: 1
Server: WSAMZN-SMPBI68A
Category: System.Private.CoreLib
Message: Collection was modified; enumeration operation may not execute.
StackTrace: at System.Collections.Hashtable.HashtableEnumerator.MoveNext()
at Microsoft.PowerShell.Commands.JsonObject.ProcessDictionary(IDictionary dict, Int32 depth, ConvertToJsonContext& context)
at Microsoft.PowerShell.Commands.JsonObject.ProcessValue(Object obj, Int32 currentDepth, ConvertToJsonContext& context)
at Microsoft.PowerShell.Commands.JsonObject.ProcessEnumerable(IEnumerable enumerable, Int32 depth, ConvertToJsonContext& context)
at Microsoft.PowerShell.Commands.JsonObject.ProcessValue(Object obj, Int32 currentDepth, ConvertToJsonContext& context)
at Microsoft.PowerShell.Commands.JsonObject.ConvertToJson(Object objectToProcess, ConvertToJsonContext& context)
at Microsoft.PowerShell.Commands.ConvertToJsonCommand.EndProcessing()
at System.Management.Automation.CommandProcessorBase.Complete()
Metadata
Metadata
Assignees
Labels
Projects
Status