OpenWA icon indicating copy to clipboard operation
OpenWA copied to clipboard

[Bug]: Error 503 Dashboard after restart

Open onepay-ye opened this issue 4 months ago • 1 comments

Pre-flight

  • [x] I searched existing issues and this isn't a duplicate
  • [x] I'm on the latest released version (or noted my version below)

OpenWA version

0.12.1

Deployment

Docker Compose

Database

SQLite (default)

WhatsApp engine

whatsapp-web.js

What happened?

Dashboard displays error code 503 until several manual updates are performed, after which the dashboard appears normally.

Steps to reproduce

Wait for 10 to 12 seconds, then manually refresh the browser.

Expected behavior

No response

Relevant logs


Environment / additional context

No response

onepay-ye avatar Jul 31 '26 13:07 onepay-ye

@onepay-ye — found it, and your description in the other thread was the thing that pointed at it. You wrote that previous versions "would restart and wait until the health API was checked" while the current one "restarts quickly and returns to the 503". That is exactly what happens, and the reason is that the wait is not real.

What is going on

The restart modal polls the server and reloads the page once it answers. It polls GET /api/infra/health, which is a plain ping — it returns ok unconditionally and knows nothing about a shutdown in progress.

When you press Restart, the server drains before exiting. Throughout that drain, and throughout the engine teardown that follows it, /api/infra/health keeps answering 200. The first poll happens three seconds after the restart request, which is precisely when the old process is still there and still answering. So the modal is told "the server is back" by the very process it just asked to shut down.

It then reloads the page two seconds later. By that point the old process has exited and the new one has not finished booting, so your browser gets a 503 from your reverse proxy. Refreshing by hand a few times works because eventually the new process is up — you are simply waiting out the boot manually, which is what the modal should have done for you.

The 503 itself comes from your proxy, not from OpenWA. But the reload that ran into it is ours.

I measured this rather than assuming it. Running the published image, sending it a shutdown signal and polling both health endpoints once a second:

t     /api/infra/health   /api/health/ready
0s    200                 503
1s    200                 503
...   200                 503
9s    200                 503

The endpoint the dashboard polls reports success for every second of a shutdown in progress.

The fix

#1041 changes the poll to GET /api/health/ready, which reports 503 the moment draining starts and keeps reporting it until the databases answer. The page then reloads only once the new process is genuinely serving — no manual refreshing.

It also raises the poll deadline. That mattered less before, because the poll always "succeeded" immediately; now that it actually waits, a restart that brings up PostgreSQL, Redis and MinIO together could have hit the old 60-second limit and shown a failure while the stack was still coming up. The deadline now follows the estimate the server itself returns.

Meanwhile

Nothing is broken by this — the restart completes correctly either way, the page just reloads too early. If it is in your way, waiting ~15 seconds before refreshing once is more reliable than refreshing repeatedly, since each early refresh lands in the same gap.

Thank you for filing this separately when I asked. It was a distinct bug with a distinct cause, and keeping it out of #981 is what made both tractable.

rmyndharis avatar Aug 01 '26 12:08 rmyndharis