Vibe Coded App Error Handling: Fix Blank Screen Bugs
Vibe coded app error handling is usually missing rather than wrong. AI coding tools generate the happy path described in your prompt, so the app works when the network works, the database has rows and the user types valid input. The moment a request fails, a list comes back empty or a session expires, there is no code to handle it — so the user gets a blank screen, a spinner that never stops, or a raw error dumped on the page. Fixing it means deliberately building four states for every screen that loads data: loading, empty, error and success.
Why does vibe coded app error handling break so often?
Because of how the code gets written. You prompt for an outcome — “show the user's invoices in a table” — and the model produces code that does exactly that, assuming the fetch succeeds and returns rows. Nothing in the prompt describes what should happen when the API returns a 500, so nothing in the output handles it.
Three things make the gap easy to miss:
- The preview always works. You test on your own machine, logged into your own account, with seeded data and a fast connection. That is the one environment where the happy path is the only path.
- Failure states are invisible until they fire. A missing empty state looks identical to a working screen right up to the day a real user signs up and has no data yet.
- Each state is separate code. Loading, empty and error are not variations of one thing. They are three extra branches per data-loading component, and AI-generated code rarely writes branches you did not ask for.
This is the same root cause behind most AI-generated code bugs: the model optimises for the described case, and silence about everything else reads as permission to skip it.
What are the four states every screen needs?
Use this as the specification for every component that loads data. If a screen cannot render all four, it is incomplete.
| State | When it fires | What the user should see | Common vibe-coded failure |
|---|---|---|---|
| Loading | Request in flight | Skeleton or spinner, with the page shell already visible | Blank white area, or a spinner that never clears because the error path never sets loading to false |
| Empty | Request succeeded, zero results | A sentence explaining there is nothing yet, plus the action that creates the first item | An empty table with headers only, or a bare page that looks broken |
| Error | Request failed, or returned a non-2xx status | Plain-language message and a retry button | Nothing at all, a raw stack trace, or [object Object] |
| Success | Data returned | The content | Usually fine — this is the only state that was built |
Where do the blank screens actually come from?
Blank screens are the signature symptom, and in AI-generated front-end code they have a short list of causes worth checking by hand:
1. fetch does not throw on 4xx or 5xx
This trips up generated code constantly. The browser Fetch API only rejects on a network-level failure; a 404 or a 500 resolves normally with response.ok set to false. Code that wraps a fetch in try/catch and nothing else will sail straight past a server error and then try to read .map() off an error object. Check response.ok explicitly, or use a client that throws on non-2xx.
2. An ignored error field in the client response
Database and backend SDKs commonly return a result shape like { data, error } rather than throwing. Generated code frequently destructures data and never looks at error, so a permission failure or a bad query silently becomes data: null — and the component renders nothing. Grep your project for destructured results and confirm every single one checks the error.
3. An uncaught error during render
In React, an error thrown while rendering unmounts the component tree above it unless an error boundary catches it. That is literally how you get a white page instead of a broken widget. One top-level error boundary turns a total blackout into a contained “something went wrong, retry” panel. AI-generated scaffolds rarely include one.
4. Reading a property off undefined
Generated code tends to assume nested data is present: user.profile.name, order.items[0].price. Any one missing link throws. Optional chaining and a sensible fallback value are cheap; finding the crash in production is not.
5. A loading flag that is never reset
If setLoading(false) lives only in the success branch, every failure leaves the spinner on screen forever. Put it in a finally block.
How do you test error handling without a QA team?
You cannot find these states by using the app normally, because normal use is the happy path. You have to force the failures. Each of these takes under a minute in browser devtools:
- Go offline. Network tab → Offline, then click through your main flows. Every screen should say something, not freeze.
- Block one request. Use request blocking on your API URL pattern, or set throttling to a slow profile. This separates “slow” from “broken” — and slow is where missing loading states show up.
- Sign up as a brand-new user. A fresh account with zero data is the only reliable way to see your empty states. Do this in a private window so you are not reusing your seeded account.
- Submit bad input. Empty required fields, a 500-character name, an email with no domain, a negative quantity, an emoji in a number field.
- Double-click every submit button. Unguarded handlers create duplicate records — a data bug, not just a UI one.
- Let the session expire. Clear your auth cookie or token in Application storage, then interact with the page. A good app routes you to login; a vibe-coded one often renders an empty shell.
Write the results down as test cases rather than fixing them ad hoc. Once you have the list, the next step is making it repeatable — see how to add tests to a vibe-coded app for turning a manual pass like this into checks that run on every deploy.
What should an error message actually say?
A good error message answers three questions in plain language: what happened, whether the user can do anything about it, and what to do next. “We couldn't load your invoices. Check your connection and try again” with a retry button beats both silence and TypeError: Cannot read properties of undefined.
Two rules worth enforcing project-wide:
- Never render a raw exception to the user. Stack traces and database errors can expose table names, file paths and query structure. Log the detail; show the human a summary.
- Always offer a way forward. Retry, go back, or contact support. A dead end with no action is the state people screenshot and send to you — or abandon.
How can AI QA catch error-handling gaps before clients do?
The manual pass above works, but it only covers the screens you remembered to check, on the day you checked them. Automating the forced-failure pass is what keeps it honest as the app grows.
That is the job Klavity does. Sims runs AI personas through your real flows the way an unfamiliar user would — including the awkward paths, blank forms and dead ends that hand-written tests skip. AutoSim turns the flows that matter into self-healing end-to-end tests, so a missing error state that gets fixed today does not quietly reappear after next week's AI-assisted refactor. And Snap gives clients and teammates a right-click bug report that carries the console error, network log and screenshot with it, so a “the page is just blank” message arrives with the evidence you need to fix it attached.
If you want the broader picture of how this fits together, start with our complete guide to AI QA. If slowness is the complaint rather than crashes, vibe coded app performance issues covers the other half of the problem.
The shortest version
Every screen that loads data needs four states, not one. Check response.ok, check the error field, add an error boundary, reset loading in a finally. Then force the failures — offline, blocked request, fresh account, expired session — before a client does it for you.
Try Klavity free and let AI personas hunt the blank screens in your app before your users find them.
Key takeaways
- Build four states per data screen: loading, empty, error, success.
- Check response.ok — fetch does not throw on 4xx or 5xx.
- Add one top-level error boundary to stop blank-screen blackouts.
- Force failures: offline, blocked request, new account, expired session.
FAQ
Why does my vibe coded app show a blank white screen?
Most often an uncaught error during render. In React, an error thrown while rendering unmounts the component tree unless an error boundary catches it, so a single broken widget takes the whole page with it. The other common causes are reading a property off undefined and rendering a response that was actually an error, because the Fetch API resolves normally on a 404 or 500 instead of throwing.
Why does my spinner never stop?
Because the loading flag is only reset in the success branch. If setLoading(false) lives inside the try block or after the successful response, any failure leaves it true forever. Move it into a finally block so it runs on every path.
What is the fastest way to test error handling by hand?
Four checks in browser devtools, each under a minute: switch the Network tab to Offline and click through your flows; block your API URL pattern to simulate a server failure; sign up as a brand-new user in a private window to see your empty states; and clear your auth token in Application storage to simulate an expired session.
Should error messages show the technical error?
No. Stack traces and database errors can expose table names, file paths and query structure, and they tell the user nothing useful. Log the technical detail on the server and show a plain-language message that says what happened and offers a retry or a way back.
Catch bugs the moment a human sees them
Klavity: right-click bug reports, AI personas that review your product, and self-healing tests.
Get started free