Skip to content

feat: serve lightweight HTML page on 503 errors - #60

Merged
elliotechne merged 1 commit into
mainfrom
feat/503-lightweight-fallback
Mar 29, 2026
Merged

feat: serve lightweight HTML page on 503 errors#60
elliotechne merged 1 commit into
mainfrom
feat/503-lightweight-fallback

Conversation

@elliotechne

Copy link
Copy Markdown
Owner

Summary

  • Adds a minimal templates/503.html fallback page (no JS, no external resources, ~800 bytes inline CSS)
  • Adds a @app.errorhandler(503) in error_handler.py that serves the HTML page to browser clients and JSON to API clients, using the Accept header to distinguish
  • Addresses OOM-related 503s (from reduced Gunicorn workers / memory limits) so users see a readable page instead of a raw JSON error

Test plan

  • Trigger a 503 (e.g. temporarily break DB connection or call the health endpoint with DB down) and confirm a browser GET returns the HTML fallback page with status 503
  • Confirm an Accept: application/json request to a 503 endpoint still returns JSON {"error": "Service unavailable", ...}
  • Verify the 503 page loads with no external network requests (pure inline styles)

🤖 Generated with Claude Code

When the service is under memory pressure and returns 503s, browser
clients now receive a minimal static HTML fallback page (no JS, no
external resources) instead of a raw JSON error. API clients continue
to receive JSON responses. Handles the health-check and Stripe 503
paths via the new global errorhandler.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@elliotechne
elliotechne merged commit df25ef3 into main Mar 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant