Serious bug with Hangfire + SQL
Hi there,
I found a serious bug with scheduled on time jobs. Basically if you create one time scheduled job and use Set-PsuSchedule or modify time through the UI, it leaves behind orphaned schedules that will fire on PSU restart. This can lead to bad consequences if the jobs are targeting production systems. This needs to be fixed before it screws somebodies environment up. Details below:
PSU 2026.3.2: One-time schedules can run again after restart with SQL persistence
With SQL persistence enabled, PowerShell Universal (PSU) can rerun one-time schedules that already ran, were renamed, or were cancelled or deleted. Three interacting defects leave stale rows in dbo.OneTimeSchedules or leave old jobs scheduled in Hangfire.
Steps to reproduce
1. Configure PSU 2026.3.2 with SQL persistence.
2. Create a one-time schedule with New-PSUSchedule -Name "Test - T1" -OneTime ....
3. Use Set-PSUSchedule to rename it to Test - T2 and change its -OneTime timestamp.
4. Check dbo.OneTimeSchedules and HangFire.[Set] (key: schedule). Both jobs remain scheduled in Hangfire, but the old Test - T1 schedule is no longer visible to Get-PSUSchedule or removable through Remove-PSUSchedule.
5. Cancel or delete the Hangfire job so its state is Deleted. Once the corresponding OneTime timestamp is in the past, confirm that its row still exists in dbo.OneTimeSchedules, then restart PSU.
6. Observe that LoadOneTimeSchedulesAsync() re-enqueues the past-due job and it runs immediately on startup.
What happens
1. Startup re-enqueues jobs in Succeeded or Deleted state
On startup, StartupService calls JobService.LoadOneTimeSchedulesAsync(). It reads every row in dbo.OneTimeSchedules and calls IsActiveHangfireJob(backgroundJobClient, oneTimeSchedule.HangfireId).
IsActiveHangfireJob returns false when the Hangfire job is missing or its state is Deleted or Succeeded. The startup path also ignores schedule.Paused. When the check returns false, startup calls ScheduleOneTimeJob(..., allowPast: true). If OneTime is in the past, ScheduleOneTimeJob calls backgroundJobClient.Enqueue(...) and the job runs immediately.
2. Renaming a schedule leaves the old Hangfire job in place
Set-PSUSchedule and PUT /api/v1/schedule/{id} call ScheduleService.UpdateAsync(), which updates the schedule in memory, including its Name, before calling JobService.ScheduleWorkflowJob or ScheduleScriptJob.
Those methods call RemoveStoredOneTimeSchedule(schedule, backgroundJobClient), which looks up the stored row using m.Name == schedule.Name. Because the lookup uses the new name, it misses the row stored under the original name and never cancels the old Hangfire job via BackgroundJobClient.Delete.
The old job can still fire at its original scheduled time, even if Remove-PSUSchedule is later called on the renamed schedule. The orphaned SQL row can also trigger another run on startup.
3. Hangfire marks the dispatcher job Succeeded before the PSU job finishes
ScheduleOneTimeJob schedules JobDispatcher.Execute(executionOptions) and saves the dispatcher job’s ID in dbo.OneTimeSchedules.HangfireId. When the schedule fires, the dispatcher enqueues ExecutionService.Execute(executionOptions) and transitions to Succeeded while the actual script or workflow is still running.
ExecutionService.Execute removes the one-time row through RemoveOneTimeJob only at the end of execution. If PSU restarts before that cleanup finishes, LoadOneTimeSchedulesAsync() sees the dispatcher as inactive and enqueues a second copy. IsJobRunningScheduleAsync blocks the second copy from starting only if the original PSU job is still in Running state.
Expected behavior
- On update: Remove the old dbo.OneTimeSchedules row and cancel its Hangfire job using the original schedule name or a persistent schedule ID before creating the replacement.
- On startup: Respect Paused and do not re-enqueue past-due one-time schedules or jobs already in Deleted or Succeeded state.
- On cancellation, deletion, or dispatch: Reliably remove the stored one-time schedule row so startup cannot dispatch it again.
Workaround
Avoid editing -OneTime schedules in place through Set-PSUSchedule, PUT /api/v1/schedule/{id}, or the Admin Console. Use Remove-PSUSchedule followed by New-PSUSchedule. If orphaned dbo.OneTimeSchedules rows or corresponding Hangfire scheduled jobs already exist, clean them up before restarting PSU.
Fixes upgrading to recent versions
Product: PowerShell Universal
Version: 5.6.7Posting this in case it helps anyone having issues upgrading from earlier 5.x versions and maybe 4.x. I had a ton of issues with none of my apps starting (only integrated env was working), endpoints not working and universal service crashing out. The following two changes seems to have clear everything up for me:
Create system environment variable NO_PROXY = 127.0.0.1,localhost (not sure why this does anything since our proxy is only for external but I found it elsewhere on the board and seemed to help)
In appsettings.json add “CorsHosts” setting with all your FQDN/URLs for powershell universal i.e.: “CorsHosts”: “http://localhost;https:/localhost;https://pud.mydomain.com” (this may get added for new installs but the upgrade doesn’t seem to touch your existing appsettings.json AFAIK)
These two settings seem to have fixed all kinds of issues for me after upgrading our dev instance.
Issues when using New-UDButton -OnClick with Multiple Sessions
Hosting it via Windows Service through the MSI install. I tried Firefox and Edge as well, same results in all browsers.If you are unable to reproduce, I’ll have a look at our config, perhaps some setting we added that’s causing this. Will report back If I find anything.
Issues when using New-UDButton -OnClick with Multiple Sessions
Here’s a simple one:
If you edit dashboard, save and reload, when your tab refreshes the dynamic table will not be visible (first clue its broken).
If you navigate to the “Blank” page, then navigate back to “Hello World” it loads properly again.
Not Working:

Working:

$Pages = @()
$Pages += New-UDPage -Name 'Hello World' -Content {
New-UDPaper -Id "ppr-root" -Style @{"max-width"="500px";} -Children {
New-UDGrid -Container -Children {
New-UDGrid -MediumSize 12 -Children {
New-UDTypography -Text "Enter a hostname"
}
New-UDGrid -MediumSize 12 -Children {
New-UDTextbox -Id "txt_hostname" -Placeholder "Enter a Hostname" -FullWidth -Multiline
}
New-UDGrid -MediumSize 6 -Children {
New-UDButton -Text "Create Folder(s)" -OnClick {
$Hostname = (Get-UDElement -Id "txt_hostname").Value
Show-UDToast -Message "Hostname: $HostName" -Duration 1000 -Position topCenter
$StatusObj = [PSCustomObject] @{
Hostname = $Hostname
Status = "Queued"
}
Sync-UDElement "dyn_tbl_results" -ArgumentList $StatusObj
}
}
}
}
New-UDDynamic -Id "dyn_tbl_results" -Content {
New-UDTable -Title "Folder Create - Results" -Data $ArgumentList -Columns @(
New-UDTableColumn -Property Hostname
New-UDTableColumn -Property Status
)
}
}
$Pages += New-UDPage -Name "Blank" -Content {
New-UDTypography -Text "Hello World"
}
New-UDApp -Title "Hello World" -Pages $PagesIssues when using New-UDButton -OnClick with Multiple Sessions
Little more clarification on this:
This is tested on version 4.1.7 not 4.1.8
What’s happening is if you edit a dashboard/page, after the reload certain elements on the page do not work. These include Forms and the submit button, dynamic regions, etc.
If you then navigate to a different page in the same dashboard then navigate back to the original page with the issue, everything loads fine.
Working around it for now but highlighting it as an issue that can lead to frustration if you don’t know how to work around it while editing an app/dashboard.
Issues when using New-UDButton -OnClick with Multiple Sessions
Hi Team,
We have a simple app/dashboard where we get a computer name from a textbox and the user clicks a button and it performs simple tasks (create a folder with that PC name lets say). What we are running into during testing is that when the app code is updated, app is restarted and refresh button is clicked (within PU), many times the onclick event does nothing (no errors, no feedback).
At this point only way to make it work again is to make sure to close all tabs and open a new session. Is this behavior expected? I saw a similar issue saying endpoints and such stop working after 5 tabs/session from one user. We at most had 2 sessions and on click would fail to work leading to a frustrating experience from one of my team members trying to learn and code PU apps. We are able to recreate in 4.0.9 and latest 4.1.8 Any suggestions are appreciated. Thanks.
Product: PowerShell Universal
Version: 4.1.8