Skip to content

[BUG] Dashboard crashes with unhandled error when GitHub OAuth token expires mid-session #3244

Description

@Nareshkumawat-star

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

  1. Sign in to DevTrack
  2. Let the session sit until the GitHub token expires (or manually revoke the token in GitHub Settings → Applications)
  3. Trigger a data fetch (change time range, reload a widget)
  4. 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

Metadata

Metadata

Labels

gssoc:assignedGSSoC: Issue assigned to a contributor

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions