From b1c862e7e302e34152704bc8b2047bf08aabb64c Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 3 Mar 2026 19:27:17 -0800 Subject: [PATCH] fix: prevent unhandled promise rejection for scheduler status fetch Attach .catch at promise creation to mark it as handled by the runtime, then check the result type after await. This prevents an unhandledrejection event if the fetch rejects before the await. Co-Authored-By: Claude Opus 4.6 --- weed/admin/view/app/plugin.templ | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/weed/admin/view/app/plugin.templ b/weed/admin/view/app/plugin.templ index d5114950d..fcd140781 100644 --- a/weed/admin/view/app/plugin.templ +++ b/weed/admin/view/app/plugin.templ @@ -2847,16 +2847,17 @@ templ Plugin(page string) { var allJobsPromise = pluginRequest('GET', '/api/plugin/jobs?limit=500'); var allActivitiesPromise = pluginRequest('GET', '/api/plugin/activities?limit=500'); var schedulerPromise = pluginRequest('GET', '/api/plugin/scheduler-states'); - var schedulerStatusPromise = pluginRequest('GET', '/api/plugin/scheduler-status'); + var schedulerStatusPromise = pluginRequest('GET', '/api/plugin/scheduler-status').catch(function(e) { return e; }); var allJobs = await allJobsPromise; var allActivities = await allActivitiesPromise; var schedulerStates = await schedulerPromise; + var schedulerStatusResult = await schedulerStatusPromise; var schedulerStatus = null; - try { - schedulerStatus = await schedulerStatusPromise; - } catch (e) { - console.error('Failed to fetch scheduler status:', e); + if (schedulerStatusResult instanceof Error) { + console.error('Failed to fetch scheduler status:', schedulerStatusResult); + } else { + schedulerStatus = schedulerStatusResult; } state.jobs = Array.isArray(allJobs) ? allJobs : [];