The screen said success. The database had nothing. How do you catch swallowed failures?
I was testing a feature that records a small flag (a user ID, a level, and a timestamp) whenever the app shows a specific page to a user. On my preview deploy, the page showed exactly as designed. Then I opened the table: zero rows.
The cause was boring. The preview environment had no service-role key, so creating the database client failed. The code logs the error and moves on, on purpose, because the user should never be stuck waiting on a database write before seeing that page. But it also meant everything looked fine: the right page, a 200 response, no visible error. Preview sign-in works with the URL and anon key alone, so nothing else broke. The only trace was one log line, and a lock that depends on that row was quietly off too.
What I’m changing: add the key to the preview environment, redeploy, and re-test by reading the table, not the screen.
The tradeoff I keep going back and forth on: swallowing the error is right for the user, and wrong for me.
How do you catch failures like this in serverless apps, where the user sees success? Alerts on specific log lines, a health check that writes and reads a test row, tests that query the database after the action, or something else?
Replies
Be the first to reply
Have a question or a thought to share? Add a comment above to start the conversation.