Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(background-tasks): no state update after unmount when the features answer arrives late

Mauriced7bf7f2f1656
diff --git a/client/src/components/BackgroundTasks/BackgroundTasksWidget.tsx b/client/src/components/BackgroundTasks/BackgroundTasksWidget.tsx
index 087464442..c36cf2226 100644
--- a/client/src/components/BackgroundTasks/BackgroundTasksWidget.tsx
+++ b/client/src/components/BackgroundTasks/BackgroundTasksWidget.tsx
@@ -43,7 +43,12 @@ export default function BackgroundTasksWidget() {
const [aiParsing, setAiParsing] = useState(false)
useEffect(() => {
- healthApi.features().then((f) => setAiParsing(!!f.aiParsing)).catch(() => setAiParsing(false))
+ // Cancelled on unmount, so a late answer never sets state on a torn-down widget.
+ let cancelled = false
+ healthApi.features()
+ .then((f) => { if (!cancelled) setAiParsing(!!f.aiParsing) })
+ .catch(() => { if (!cancelled) setAiParsing(false) })
+ return () => { cancelled = true }
}, [])
// Re-runs the same files with force-ai: the LLM sees every file, kitinerary is skipped.