feat(app): expose boot() so providers can fail before serving

Only listen() booted before accepting traffic. Deno, Bun and edge all boot on the
first request, and the memo keeps the rejection, so a bad key answered 500 for the
life of the process while the app looked healthy.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-09-16 22:26:28 -05:00
1 parent 80f3f532f2
commit 3fc761ce16
3 files changed
+75

No files matched your search

+1
View File
@@ -392,6 +392,7 @@ export function createApp(opts: {
close,
handleSignals,
ready,
boot: bootApp,
fetch: fetchFn,
upgrade: upgradeFn,
inspect,
+15
View File
@@ -59,6 +59,21 @@ export interface App {
* shares this same memoized step — calling both never resolves the graph twice.
*/
ready(): Promise<void>;
/**
* Boots the providers now, instead of on the first request.
*
* `listen()` already does this before it accepts a connection. Every other path — `app.fetch`,
* `app.upgrade`, `serveDeno`, `serveBun`, `edgeHandler` — boots lazily on the first request, and a
* provider that throws there fails *every* request, answered by the runtime with a 500 that never
* reaches `onError`. Calling this first turns that into a startup failure, which is where a bad
* key or an unreachable database belongs.
*
* Idempotent, and shares its memo with `listen()` and `fetch()`: calling both boots once. Unlike
* `ready()`, it does run provider factories.
*
* On workerd there is no startup outside a request, so calling it moves nothing.
*/
boot(): Promise<void>;
/** Web-Standards handler: run a Fetch API Request through the graph and return a Response (Node/Deno/Bun/edge). WS not included. */
fetch(request: Request): Promise<Response>;
/** Run a WebSocket upgrade through the graph using an adapter-provided socket (Deno/Bun/edge). Node uses its own listener path. */