Skip to content

feat(web): silent refresh on 401 with single-flight and auth failure notification - #51

Open
Leancoggiola wants to merge 1 commit into
developfrom
feat/auth-refresh-invalidation
Open

feat(web): silent refresh on 401 with single-flight and auth failure notification#51
Leancoggiola wants to merge 1 commit into
developfrom
feat/auth-refresh-invalidation

Conversation

@Leancoggiola

Copy link
Copy Markdown
Owner

Ticket

Closes #34

Resumen

Refresh silencioso en web ante 401: single-flight refreshSession, retry único en fetcher.ts (GET) y client.ts (mutaciones), y notificación a AuthContext para limpiar la caché SWR completa cuando el refresh falla (logout claro).

Área

  • web
  • api
  • mobile
  • shared
  • infra / docs

Checklist

  • Issue en Omni Roadmap en En revisión
  • Branch sigue feat/#N-slug
  • Si toca contrato: orden sharedapi → clientes (N/A, no toca contrato)
  • Verificación local:
pnpm --filter web check-types && pnpm --filter web lint && pnpm --filter web check-api-paths && pnpm --filter web test

Todo OK (51/51 tests, 23 nuevos). Smoke manual verificado: refresh silencioso ante access token vencido, logout claro cuando el refresh también falla, y single-flight ante requests concurrentes.

Notas / capturas

  • Nuevo módulo apps/web/src/shared/api/refreshSession.ts con ensureRefreshed (single-flight) y el puente setOnAuthFailure/notifyAuthFailure.
  • Paridad con el patrón ya usado en apps/mobile/src/shared/api/client.ts.

…notification

Adds a shared refreshSession module with single-flight refresh and an
auth-failure callback bridge. fetcher.ts and client.ts now retry once on 401
after a successful /api/auth/refresh, and notify AuthContext to clear the
SWR cache when refresh fails.

Closes #34
@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
omni-web Ready Ready Preview Aug 6, 2026 4:31pm

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.

[US] Refresh silencioso en web ante 401

1 participant