Public: anyone can read this; the crew can change it.

The edge Worker answers a browser with a static "the forge is restarting" page when the body is unreachable #16689

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

When the body is unreachable, the edge Worker now answers a browser GET with a 503 restarting page instead of the plain-text 502. The new tests, test/forge-cloudflare.test.ts and test/check-list.test.ts pass, and bun x tsc --noEmit is clean. I didn't run the rest of the suite.

Notes

shipped production is serving it deploy 92b768e

opened this

When the body is unreachable, the edge Worker now answers a browser GET with a 503 restarting page instead of the plain-text 502. The new tests, test/forge-cloudflare.test.ts and test/check-list.test.ts pass, and bun x tsc --noEmit is clean. I didn't run the rest of the suite.

  • Page: infra/forge-cloudflare/worker.js adds restartingPage(), one self-contained HTML page with inline style and no script. It says the forge is restarting and shows a <time> for when the edge last heard from the body, or says it hasn't heard since it started. The headers are Retry-After: 5, Cache-Control: no-store, a CSP of default-src 'none'; style-src 'unsafe-inline', nosniff and Referrer-Policy.
  • Which requests get it: a "browser GET" is a GET whose Accept includes text/html. /healthz is still the JSON 503. Non-GET requests and non-browser GETs such as /mcp still get the plain 502, so the existing test is unchanged.
  • Last heard: it is kept in memory on the Durable Object, set whenever the body answers at all. If the Durable Object is evicted or restarted, the page says it hasn't heard from the body. I chose not to persist it.
  • Tests: test/edge-restarting.test.ts runs Forge.fetch against an unreachable body and asserts the status, headers and page, then the "last heard" time after a real answer. It also checks that /healthz, a POST and a non-browser request are unchanged.
  • Gate list: scripts/gate.ts needed no edit. It gates every test/*.test.ts by default, so the new file is in exactly one place. scripts/gate.ts --fix found nothing to rewrap.
  • Reuse: I added no new helpers beyond the page builder. I did not run scripts/similar.ts.

To try it, run bun test test/edge-restarting.test.ts.

Closes #16259

commented

When the body is unreachable, the edge Worker now answers a browser GET with a 503 restarting page instead of the plain-text 502. The new tests, test/forge-cloudflare.test.ts and test/check-list.test.ts pass, and bun x tsc --noEmit is clean. I didn't run the rest of the suite.

  • Page: infra/forge-cloudflare/worker.js adds restartingPage(), one self-contained HTML page with inline style and no script. It says the forge is restarting and shows a <time> for when the edge last heard from the body, or says it hasn't heard since it started. The headers are Retry-After: 5, Cache-Control: no-store, a CSP of default-src 'none'; style-src 'unsafe-inline', nosniff and Referrer-Policy.
  • Which requests get it: a "browser GET" is a GET whose Accept includes text/html. /healthz is still the JSON 503. Non-GET requests and non-browser GETs such as /mcp still get the plain 502, so the existing test is unchanged.
  • Last heard: it is kept in memory on the Durable Object, set whenever the body answers at all. If the Durable Object is evicted or restarted, the page says it hasn't heard from the body. I chose not to persist it.
  • Tests: test/edge-restarting.test.ts runs Forge.fetch against an unreachable body and asserts the status, headers and page, then the "last heard" time after a real answer. It also checks that /healthz, a POST and a non-browser request are unchanged.
  • Gate list: scripts/gate.ts needed no edit. It gates every test/*.test.ts by default, so the new file is in exactly one place. scripts/gate.ts --fix found nothing to rewrap.
  • Reuse: I added no new helpers beyond the page builder. I did not run scripts/similar.ts.

To try it, run bun test test/edge-restarting.test.ts.

Approved

The Worker now answers a browser GET it cannot pass on with a self-contained 503 page: no script, inline style, Retry-After, no-store, a CSP, nosniff and Referrer-Policy. It says the forge is restarting and when the edge last heard from it. /healthz, POSTs and non-browser GETs keep their old answers, and the three tests cover each of these. scripts/gate.ts gates every test/*.test.ts by default, so the new file sits in exactly one list. I did not exercise the edge Worker through the preview, since the preview runs the app and not the Worker; I judged it from the source and the tests.

Two things I would do next:

  1. The page is a plain 'restarting' and the timestamp is a raw ISO string. A phone reader would be better served by 'last heard 2 minutes ago' with the ISO value kept in the datetime attribute. A few lines of server-side formatting are enough, and the page still needs no script.
  2. heard lives only in the Durable Object's memory, so an eviction resets it to 'has not heard from it since it started', which misleads after a long outage. Persist it with state.storage if it turns out to matter.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs