Describe the bug
When a user's GitHub OAuth access token expires while they are actively viewing the dashboard, the Next.js API route handlers (/api/metrics/*) return 401 from GitHub's API. This is not caught gracefully — the component either freezes in a loading state or logs an unhandled error to the console without showing any user-facing message.
Steps to reproduce
- Sign in to DevTrack
- Let the session sit until the GitHub token expires (or manually revoke the token in GitHub Settings → Applications)
- Trigger a data fetch (change time range, reload a widget)
- Dashboard shows a blank/broken state with no message
Expected behavior
- API routes should detect a 401 from GitHub and return a structured error (e.g.
{ error: 'session_expired' })
- Components should catch this and show a toast: "Your session expired — please sign in again"
- Auto-redirect to
/api/auth/signin after 3 seconds
Files to check
src/app/api/metrics/contributions/route.ts
src/app/api/metrics/prs/route.ts
src/components/ContributionGraph.tsx (error boundary)
Environment: Next.js 14 App Router, NextAuth.js
Describe the bug
When a user's GitHub OAuth access token expires while they are actively viewing the dashboard, the Next.js API route handlers (
/api/metrics/*) return 401 from GitHub's API. This is not caught gracefully — the component either freezes in a loading state or logs an unhandled error to the console without showing any user-facing message.Steps to reproduce
Expected behavior
{ error: 'session_expired' })/api/auth/signinafter 3 secondsFiles to check
src/app/api/metrics/contributions/route.tssrc/app/api/metrics/prs/route.tssrc/components/ContributionGraph.tsx(error boundary)Environment: Next.js 14 App Router, NextAuth.js