TypeScript compiles cleanly (0 errors). Your preview looks great on localhost. Then a real user opens the app in production and hits a blank white screen.
When AI builders (Lovable, Cursor, Bolt, Replit) generate Vite + React + Supabase apps fast, three runtime failure patterns slip straight past tsc without a single compiler warning:
- Unguarded
JSON.parse()onlocalStorageor API payloads - Fire-and-forget async calls missing
awaitinsidetry/catch/finally - Unsafe
catch (error: any)dereferencing.messagewhen non-Errorvalues reject
Here is a real case study from auditing a 157-file public Lovable app (gsm-fullweb/careconnect) completely offline in local static analysis — and how to fix all 4 defects without letting an AI chat rewrite your working UI.
1. Real-World Repo Anatomy (gsm-fullweb/careconnect)
Running a local Pure-AST scan across src/ (157 files) flagged 4 silent runtime bugs across 3 files:
Defect A — Crashing Dashboard Mount on Corrupted localStorage (src/pages/ClientDashboard.tsx:465)
// Before (compiles cleanly in tsc, throws SyntaxError in production) const favoritosLocal = localStorage.getItem(`favoritos_${user?.id}`); if (favoritosLocal) { setFavoritos(JSON.parse(favoritosLocal)); } If any older deploy or browser extension left malformed JSON under that key, calling JSON.parse() outside try/catch (and without Array.isArray()) crashes the entire dashboard component tree on mount.
Surgical Fix:
if (favoritosLocal) { try { const parsed = JSON.parse(favoritosLocal); setFavoritos(Array.isArray(parsed) ? parsed : []); } catch { localStorage.removeItem(`favoritos_${user?.id}`); setFavoritos([]); } } Defect B — Missing await Bypassing try/catch & Loading State (src/pages/ClientDashboard.tsx:532)
// Before: loading spinner stops BEFORE loadMeusDepoimentos() resolves or rejects try { await supabase.from('depoimentos').insert(payload); loadMeusDepoimentos(); // Missing await! } finally { setLoading(false); } Adding await loadMeusDepoimentos() keeps both the fetch lifecycle and error handling synchronized inside try/catch/finally.
Defect C & D — Post-Signup Render & Catch Shadowing (src/pages/Obrigado.tsx:15 & BlogPostEditor.tsx:100)
-
Obrigado.tsxcalledJSON.parse(fallbackUser)outsidetry/catchand immediately readuserData.name. -
BlogPostEditor.tsxinterpolatederror.messagedirectly inside a shadowedcatch (error: any)block, throwing if a Supabase or network rejection wasn't anErrorinstance.
2. Why Re-Prompting AI Chat Often Makes It Worse
When you paste that runtime error back into an AI prompt, the model frequently regenerates the entire component file — silently changing working Tailwind classes, breaking auth redirects, or deleting working state hooks.
Instead of guessing with another LLM prompt, you can verify and patch only the broken AST nodes locally (0 Bytes uploaded, with instant 1-Click Undo/Redo and .xapbug/snapshots/ backups):
3. Verification Output After Repair
After applying the surgical patch across those 3 files:
-
xapbug --no-self-heal src/: 157 files analyzed —ΣQ=0 · 0 code defects(4 → 0) -
npx tsc --noEmit: exit0 -
npm run build(vite build): pass (✓ built in 10.17s,1,907 modules) -
git apply --reverse --check: clean
4. Reproduce Locally in 10 Seconds (Free Forever CLI)
- Unlimited Free CLI (local terminal & CI):
npx xapbug ./src --auto-fix - Cursor / Antigravity IDE Extension (Open VSX): Install
xapbug.xapbug(0 Bytessent to cloud). - No-Install Browser Sandbox (Drag & Drop Folder or GitHub URL): Test your project directly in local WebAssembly with a 7-Day Unlimited Multi-File Pass: 👉 Open XapBug Web IDE
More Lovable audit benchmarks & case studies:
