You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(prompts): navigating away mid-load fires a spurious "Failed to load prompt data" toast #394
Navigating away from Prompts (/dashboard/prompts) while its data is still loading fires a "Failed to load prompt data" error toast — on the page you just navigated to.
Repro:
Open /dashboard/prompts (or switch to it from the sidebar)
Quickly click another sidebar item before the page finishes loading
The destination page shows the "Failed to load prompt data" toast, even though nothing actually failed
}catch(err){console.error('Failed to load prompt data:',err);toast.error('Failed to load prompt data');}
When the route changes mid-flight, the in-flight Server Action fetches are aborted; the rejection lands in this catch, and since the sonner toaster lives in the persistent layout, the toast surfaces on the next page. There's no cancellation guard distinguishing "component unmounted / navigation aborted" from a real failure.
Fix
Use the cancellation-flag pattern that already exists elsewhere in the codebase (e.g. the report detail page):
Track a cancelled flag in the effect (set in the cleanup) and skip both the state updates and the toast.error when it's set, and/or
Ignore AbortError-shaped rejections in the catch.
Same pattern elsewhere (optional sweep)
The same unguarded catch → toast.error('Failed to load …') exists in at least:
dashboard/insights/page.tsx (~413, "Failed to load prompts")
dashboard/content/page.tsx (~181) and dashboard/content/[id]/page.tsx (~107)
Hi @gkhngyk, could you please assign these issues to me? I've already started working on them, and assigning them will help avoid duplicate PRs. Thanks!
Activity
Sam-syntax35 commentedon Jul 10, 2026
Hi @gkhngyk, could you please assign these issues to me? I've already started working on them, and assigning them will help avoid duplicate PRs. Thanks!