From d2d6a0083fdd51415c420d8e18a69ca216b4d70c Mon Sep 17 00:00:00 2001 From: Matthew Kelly Date: Mon, 21 Oct 2024 09:11:02 +0100 Subject: [PATCH] #1408: Fixes collection modified error when cleaning up sessions --- src/Private/Sessions.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Private/Sessions.ps1 b/src/Private/Sessions.ps1 index 4e9bc870c..a3768d4b4 100644 --- a/src/Private/Sessions.ps1 +++ b/src/Private/Sessions.ps1 @@ -290,7 +290,7 @@ function Set-PodeSessionInMemClearDown { # remove sessions that have expired, or where the parent is gone $now = [DateTime]::UtcNow - foreach ($key in $store.Memory.Keys) { + foreach ($key in $store.Memory.Keys.Clone()) { # expired if ($store.Memory[$key].Expiry -lt $now) { $null = $store.Memory.Remove($key)