My Lovable App Keeps Crashing in Production — How to Debug It
You vibe-coded an app with Lovable, it works in preview, then crashes in production. Here's why it happens and how to see the actual error — without being a developer.
You built an app with Lovable. It looked great in the preview. You clicked "Publish." Then users started hitting 500 errors. You opened the Lovable editor, checked the code, and... it looks fine. You refreshed the preview — it works. What gives?
This is the #1 pain point for Lovable users. Your app works locally but crashes in production, and you can't see why because Lovable's editor doesn't show production logs. This post explains exactly what's happening, why your crashes are invisible, and how to fix it — even if you've never debugged a production app before.
Why Lovable apps crash in production (but not in preview)
Lovable generates TanStack Start apps that deploy to Cloudflare Workers. In the Lovable preview, your app runs in a forgiving Node.js environment with plenty of memory, no CPU limits, and full error output. In production on Cloudflare Workers, the rules change:
- 128MB memory limit — if your app loads a large dataset or has a memory leak, the Worker is killed instantly. No error message, no stack trace, just a 500.
- CPU time limit — 50ms on the free plan, 30s on paid. If your app does heavy computation (parsing large JSON, processing images), it hits the limit and gets killed mid-execution.
- Cold starts — Workers spin up on-demand. If your app throws an error during startup (a missing env var, a bad import), the Worker never registers and every request fails.
- No console output —
console.login your Lovable app goes nowhere in production. Cloudflare's dashboard shows limited logs with a 15-minute delay.
The result: your app crashes, users see 500s, and you have no idea what went wrong because the error information died with the Worker.
The error you can't see: Error 1101
If you've looked at Cloudflare's dashboard, you've probably seen "Error 1101: Worker threw exception." This is Cloudflare's generic "your Worker crashed" message. It tells you that your app crashed, but not why.
Here's what's actually happening: your Worker threw an uncaught exception during request handling. Common causes in Lovable apps include:
- Accessing an undefined variable — the AI generated code that assumes a variable exists, but it doesn't in production (e.g.,
user.profile.namewhenprofileis null) - Calling an API that returns unexpected data — your app expects
{ name: "Alice" }but the API returns{ error: "rate limited" }, and the code crashes trying to read.name - Missing environment variables — the AI generated code that reads
process.env.SUPABASE_URL, but you didn't set it in Cloudflare's dashboard - JSON.parse on malformed input — a webhook or API returns invalid JSON, and
JSON.parse(body)throws
The problem: by the time the error happens, your logging SDK (if you even have one) hasn't had a chance to capture it. Sentry's Workers SDK wraps your fetch handler, but if the crash happens during module initialization or a CPU timeout, Sentry never fires.
How to actually see the error
You need a Tail Worker. A Tail Worker is a Cloudflare feature that runs after your main Worker finishes — whether it succeeded or crashed. It receives the execution outcome from Cloudflare's runtime, including:
- The uncaught exception with full stack trace
- CPU time used (so you can see if you hit the limit)
- Request URL, method, and headers
- Duration and response status
- The outcome type (ok, exception, exceededCpu, exceededMemory, etc.)
Even if your Worker dies on line 1, the Tail Worker captures it. Even if you didn't write any logging code, the Tail Worker captures it. It runs outside your app — like a security camera that watches from the outside.
FlareLog provides an open-source Tail Worker template that ships this data to a dashboard where you can search, filter, and read the actual error messages.
Step-by-step: set up crash capture for your Lovable app
1. Create a FlareLog account
Go to flarelog.dev/login and sign up (free, no credit card). You'll get an API key.
2. Add the SDK to your Lovable app
In the Lovable editor, ask the AI to add FlareLog:
Install @flarelog/sdk and add the middleware to src/start.ts.
Use the zero-config form: tanstackStartMiddleware()The AI will add something like:
// src/start.ts
import { createStart } from "@tanstack/react-start";
import { tanstackStartMiddleware } from "@flarelog/sdk/tanstack-start";
export const startInstance = createStart(() => ({
requestMiddleware: [tanstackStartMiddleware() as never],
}));This captures errors thrown during request handling. But it won't catch crashes that happen before your code runs — that's what the Tail Worker is for.
3. Deploy the Tail Worker
This is the part that catches the crashes your SDK can't see. Clone the template:
git clone https://github.com/flarelog-dev/tail-worker.git
cd tail-worker
npm install
wrangler secret put FLARELOG_API_KEYEdit wrangler.toml to point at your Lovable app's Worker:
[[tail_consumers]]
service = "your-lovable-app-worker-name"Deploy:
npm run deployNow every crash — including Error 1101, CPU timeouts, and memory exhaustion — is captured and shipped to your FlareLog dashboard.
4. (Optional) Connect Cursor or Claude for AI debugging
If you use Cursor or Claude Desktop to edit your Lovable app, add the FlareLog MCP server:
{
"mcpServers": {
"flarelog": {
"url": "https://mcp.flarelog.dev",
"headers": {
"Authorization": "Bearer fl_your_api_key_here"
}
}
}
}Now you can ask your AI: "What errors happened in production in the last hour?" and it will query your FlareLog dashboard directly — no copy-pasting error messages.
What you'll see in the dashboard
Once the Tail Worker is running, your FlareLog dashboard shows:
- The exact error message — not just "Error 1101" but the actual exception:
TypeError: Cannot read properties of null (reading 'name') - The stack trace — which file and line number caused the crash (if you have source maps)
- The request that triggered it — URL, method, headers, and body
- The traceId — so you can correlate with other logs from the same request
- CPU time and duration — so you can see if you're approaching limits
- The outcome type —
exception,exceededCpu,exceededMemory, etc.
This is the information Cloudflare's dashboard doesn't show you. With it, you can go back to the Lovable editor (or Cursor) and say: "The crash is on line 42 of api/users.ts — the API returns { error: 'rate limited' } but the code tries to read .name. Fix it."
Common Lovable crash patterns (and how to fix them)
Pattern 1: "Cannot read properties of null"
Your AI generated code that chains property access without checking for null:
const name = user.profile.name; // crashes if profile is nullFix: Use optional chaining:
const name = user?.profile?.name ?? "Unknown";Pattern 2: "fetch failed" or "Network connection lost"
Your app calls an external API that's slow or down. On Cloudflare Workers, subrequests have a 30s timeout (on paid) or 6s (on free). If the API is slow, the request fails.
Fix: Add error handling with a timeout:
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 5000);
try {
const res = await fetch(url, { signal: controller.signal });
clearTimeout(timeout);
return await res.json();
} catch (e) {
logger.logError(e);
return { error: "API unavailable" };
}Pattern 3: "Worker exceeded memory limit"
Your app loads a large dataset into memory (e.g., fetching a big JSON file and parsing it all at once).
Fix: Stream the response instead of buffering:
const res = await fetch(url);
// Don't do: const data = await res.json() // buffers entire body
// Do: stream it
const reader = res.body.getReader();
// process chunks as they arrivePattern 4: Missing environment variables
Your AI generated code that reads process.env.SUPABASE_URL, but you didn't set it in Cloudflare's dashboard or Lovable's secrets panel.
Fix: Add the env var in Lovable's project settings (under "Secrets / Environment variables"). Don't prefix it with VITE_ — that pushes it to the client bundle and leaks it.
Stop guessing, start knowing
If your Lovable app keeps crashing and you can't see why, you're not alone — it's the most common problem for vibe coders. The fix isn't to learn DevOps or hire an SRE. It's to deploy a Tail Worker that captures the crashes your SDK can't see.
With FlareLog's Tail Worker + MCP server, you get:
- Full stack traces for every crash (even Error 1101)
- Cost burn alerts before surprise bills
- AI debugging via Cursor or Claude
- 5-minute setup, no DevOps experience needed
Start free — 10k logs/month, 90-day retention, no credit card. Or read the Lovable setup guide for step-by-step instructions.
Never miss an invisible crash again
FlareLog catches the errors Cloudflare can't log. Set up the Tail Worker in 5 minutes and see every crash, timeout, and cost spike in real time.
Start logging free →