Skip to content

fix(insights): silence navigation-cancellation toast - #70

Merged
gkhngyk merged 1 commit into
mainfrom
fix/insights-navigation-toast
May 21, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
fix/insights-navigation-toast

Conversation

@gkhngyk

@gkhngyk gkhngyk commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #40.

When the user navigates away from /dashboard/insights while loadData is still in flight, Next.js surfaces an "An unexpected response was received from the server" error from the aborted stream. The destination page renders fine — the toast is purely cosmetic noise, but it scares users into thinking something broke.

The catch block of loadData now guards on a case-insensitive match of "unexpected response" and routes that one specific error to console.debug instead of toast.error. Real errors (5xx, malformed payload, etc.) still surface as toasts. The silent-refresh branch is untouched.

Case-insensitive matching is deliberate so a minor wording change in a future Next.js version doesn't reopen the issue.

Test plan

  • Open /dashboard/insights cold (no cache), 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 only suppress one specific string, not all errors)
  • Normal page load with data → loads cleanly, no toast either way
  • Silent refresh path (long-running tracking job) still warns via console.warn instead of toasting

Closes #40.

When the user navigates away from /dashboard/insights while loadData is
still in flight, Next.js surfaces an "unexpected response from the
server" error from the aborted stream. The destination page renders
fine, but the red toast scares users into thinking something broke.

Guard the catch branch with a case-insensitive match on "unexpected
response" and route those to console.debug instead of toast. Real
errors (5xx, malformed payload) still surface normally.

Case-insensitive matching is deliberate so a minor wording change in a
future Next.js version doesn't reopen the issue.
@gkhngyk
gkhngyk merged commit 5996a66 into main May 21, 2026
2 checks passed
@gkhngyk gkhngyk mentioned this pull request May 26, 2026

This branch was successfully deployed

1 active deployment
Preview — 3e8190ee Deployed May 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(insights): silence the "unexpected response" toast (navigation noise, not a real error)

1 participant