Repository navigation
Description
What's wrong
When the Answer Engine Insights page (/dashboard/insights) is still
loading and the user clicks any sidebar link to navigate away, a red
toast appears in the top-right corner:
An unexpected response was received from the server
The navigation completes correctly and the destination page renders
fine — the toast is purely cosmetic noise from the abandoned page's
in-flight requests. But it scares users into thinking something
broke.
Steps to reproduce
- Open
/dashboard/insightscold (no cache) - While spinners are still visible, click any sidebar link (Brands,
Topics, Settings, etc.) - Observe: new page loads correctly, but a red error toast
appears with the message above
What we want
Detect this specific error in the catch block and skip the toast
for it. Other real errors (a genuine server 500, a malformed payload,
etc.) should still surface normally.
Where to fix
web/src/app/[locale]/(dashboard)/dashboard/insights/page.tsx around
line 1473 — the catch block of loadData:
} catch (err) {
if (!silent) {
toast.error(
err instanceof Error ? err.message : 'Failed to load insights',
);
}
// ...
}Add a guard so this specific known-harmless message is logged but not
toasted. Suggested shape (the exact pattern is up to you):
} catch (err) {
const message = err instanceof Error ? err.message : '';
// Next.js surfaces this when a server action's response stream is
// cut because the user navigated away mid-load. Not a real error —
// the destination page renders fine.
const isNavigationCancellation =
message.includes('unexpected response') ||
message.includes('An unexpected response from the server');
if (isNavigationCancellation) {
console.debug('[insights] load aborted by navigation', err);
} else if (!silent) {
toast.error(message || 'Failed to load insights');
}
}Match the message case-insensitively if possible — Next.js wording
has shifted between versions and you want the guard to survive a
minor upgrade.
How to verify
- Open
/dashboard/insightscold, click a sidebar link while
spinners are still showing → no red toast - Stop the dev API server, reload
/dashboard/insights→ a real
error toast still appears (we're only suppressing one specific
string, not all errors) - Normal page load with data → loads cleanly, no toast either way
Out of scope
- AbortController / mounted-ref refactor — that's a bigger
architectural change; for now we only want to silence the toast - Same fix on other pages (Topics, Citations, etc.) — open a
follow-up if those pages show the same toast in the same scenario - Plan gating, error tracking integration, etc.
Contribution guide
See CONTRIBUTING.md for branch naming, commit
conventions, and PR workflow.
Activity
fix(insights): silence navigation-cancellation toast (ansvisor#70)