docs: record 'Oops' crash fix (intl + PWA middleware) verified via Playwright
Deploy to Production / test (push) Has been cancelled
Deploy to Production / deploy (push) Has been cancelled

This commit is contained in:
Patrick Plate
2026-06-13 10:45:44 +02:00
parent 4be9c4cf2c
commit 26a77b5e16
2 changed files with 210 additions and 0 deletions
+50
View File
@@ -6,6 +6,56 @@
---
## ✅ "OOPS" CRASH FIXED — 2026-06-13 (update 3) — verified in a real browser
The previous "RESOLVED" was wrong: login was verified with **curl only**, which cannot
execute client-side JS. In a real browser **every page (including `/login`) crashed on
hydration** with the "Oops! Something went wrong" boundary. Diagnosed by installing a
**Playwright browser probe** (`scripts/debug/dashboard-probe.mjs`) that logs in and
captures real console/network errors + a screenshot. Three root causes, all fixed in
commit **`4be9c4c`** (frontend rebuilt + redeployed):
8. **App-wide intl hydration crash ("Oops" on every page).** Root `app/layout.tsx`
renders global client components (`PwaInstallPrompt``useTranslations`, `Toaster`,
`Sonner`) as siblings of `{children}` inside `<Providers>`, but only each route-group
layout wrapped *its own* children in `NextIntlClientProvider`. Those global components
mounted with **no intl context** → "No intl context found" → hydration crash.
**Fix:** root layout is now `async` and wraps the body in `NextIntlClientProvider`
via `getMessages()`. Nested route-group providers remain valid (next-intl nests).
9. **PWA assets intercepted by auth middleware** (manifest.json syntax error + stale cache).
The middleware `matcher` did not exclude `/manifest.json` or `/sw.js`, so unauthenticated
browsers got **307 → /login (HTML)** for both → browser parsed HTML as JSON
(`manifest.json:1 Syntax error`) and an HTML/old service worker kept serving **stale
bundles** ("website hasn't changed after redeploy"). **Fix:** matcher now excludes
`manifest.json`, `sw.js`, `icons`, `offline`. Verified: `manifest.json` → 200
`application/json`, `sw.js` → 200 `application/javascript`.
10. **Service-worker stale cache.** Bumped `CACHE_NAME` `v1``v2` in `public/sw.js` so the
`activate` handler purges old cached bundles from clients that loaded the broken build.
**Browser verification (Playwright):** login `admin@test.de`/`test123` → lands on
`/dashboard`, **no `pageerror`**, dashboard renders. The "Oops" is gone.
### ⚠️ Known follow-up (non-fatal — dashboard renders via mock fallback)
Dashboard API endpoints are **mis-wired**: frontend calls `/api/backend/dashboard/stats`,
`/distributions/recent`, `/consent/check` → proxy rewrites to `/api/v1/dashboard/stats`
etc., but the backend has **no such routes** (real stats route is `/api/v1/clubs/me/stats`
in `ClubController`; `/dashboard` only exists in `PortalController`) → HTTP 500/404.
The dashboard falls back to `mockClubStats`/`mockRecentDistributions` so it still renders.
Frontend `ClubStats` type also differs from backend `ClubStatsResponse`. Fix = align
service paths + DTO shape, or add `/api/v1/dashboard/*` endpoints to the backend.
### 🔧 New tooling installed on the Fedora 44 workstation
- **Node.js 22.22.2 + npm 10.9.7** via `sudo dnf install -y nodejs npm` (was MISSING).
- **`@playwright/mcp` v0.0.76** (run via `npx @playwright/mcp@latest`) + Chromium
headless-shell (`npx playwright install chromium`). Wired into Roo `mcp_settings.json`
(server name `playwright`). Chromium launches fine on Fedora 44 despite the
"OS not officially supported" warning.
- **Probe:** `scripts/debug/dashboard-probe.mjs` — reusable client-side debugger.
---
## ✅ LOGIN WORKING — 2026-06-13 (update 2) — full auth flow verified
After deploy, login showed a client-side "Oops! Something went wrong" error boundary.