Closes the gap Diego spotted reading @green-tea/jwt's README, which told the reader to call app.boot() before Deno.serve / Bun.serve.
That note was accurate, and that is the problem. It documented a core helper whose correct use depended on the caller remembering something — in a framework whose argument is that order should not be a thing you have to get right.
Why the old failure was the bad kind
listen() has always done await bootApp() before binding its socket (src/app/index.ts:328), with a comment saying it exists "so Node and Deno/Bun serve an identical graph". They did not: serveDeno and serveBun were synchronous and left boot to app.fetch.
app.fetch boots lazily and the boot memo keeps the rejection. So a missing signing key was not a failed deploy:
the port binds
every request is answered 500 by the runtime
none of them reach onError
anything health-checking by "is it listening?" sees a healthy server
The change
serveDeno and serveBun are async, returning Promise<DenoServer> and Promise<BunServeResult>. The returned value is unchanged, so migration is one keyword:
- const server = serveDeno(app, { port });
+ const server = await serveDeno(app, { port });
Both runtimes support top-level await, so a module that serves at import time needs nothing else. This is what the shutdown examples already do with the result, and the app still owns its own close.
edgeHandler is deliberately untouched: on workerd there is no startup outside a request, so there is no earlier moment to move the failure to. That is now the only place the lazy path is documented, and there it is true.
Verification
Two new integration tests, one per runtime, asserting a failing provider rejects the serve call instead of binding a port that 500s. Both confirmed to bite — with await app.boot() commented out, serveBun resolves instead of rejecting and the Deno test reports <resolved>.
Gate
Result
lint / format / complexity / typecheck
pass
vitest
567 passed
Deno
18 passed
Bun
8 passed
workerd (miniflare)
PASS
deno publish --dry-run
Success
Every call site updated: 12 test files, 2 bench servers. One Bun helper (startTeapot) had to become async, which is the only non-mechanical edit.
Docs: a ### Breaking entry with the diff, and the [Unreleased]app.boot() entry rewritten — it described the old behaviour and had not shipped yet. App.boot's JSDoc now says the helpers call it and hand-calling is for app.fetch / app.upgrade driven by your own server. The README needed nothing: it has no code example using either adapter.
Closes the gap Diego spotted reading `@green-tea/jwt`'s README, which told the reader to call `app.boot()` before `Deno.serve` / `Bun.serve`.
That note was accurate, and that is the problem. It documented a core helper whose correct use depended on the caller remembering something — in a framework whose argument is that order should not be a thing you have to get right.
## Why the old failure was the bad kind
`listen()` has always done `await bootApp()` before binding its socket (`src/app/index.ts:328`), with a comment saying it exists *"so Node and Deno/Bun serve an identical graph"*. They did not: `serveDeno` and `serveBun` were synchronous and left boot to `app.fetch`.
`app.fetch` boots lazily and the boot memo keeps the **rejection**. So a missing signing key was not a failed deploy:
- the port binds
- every request is answered `500` by the runtime
- none of them reach `onError`
- anything health-checking by "is it listening?" sees a healthy server
## The change
`serveDeno` and `serveBun` are `async`, returning `Promise<DenoServer>` and `Promise<BunServeResult>`. The returned value is unchanged, so migration is one keyword:
```diff
- const server = serveDeno(app, { port });
+ const server = await serveDeno(app, { port });
```
Both runtimes support top-level `await`, so a module that serves at import time needs nothing else. This is what the shutdown examples already do with the result, and the app still owns its own close.
`edgeHandler` is deliberately untouched: on workerd there is no startup outside a request, so there is no earlier moment to move the failure to. That is now the only place the lazy path is documented, and there it is true.
## Verification
Two new integration tests, one per runtime, asserting a failing provider rejects the serve call instead of binding a port that 500s. **Both confirmed to bite** — with `await app.boot()` commented out, `serveBun` resolves instead of rejecting and the Deno test reports `<resolved>`.
| Gate | Result |
| --- | --- |
| lint / format / complexity / typecheck | pass |
| vitest | 567 passed |
| Deno | 18 passed |
| Bun | 8 passed |
| workerd (miniflare) | PASS |
| `deno publish --dry-run` | Success |
Every call site updated: 12 test files, 2 bench servers. One Bun helper (`startTeapot`) had to become `async`, which is the only non-mechanical edit.
Docs: a `### Breaking` entry with the diff, and the `[Unreleased]` `app.boot()` entry rewritten — it described the old behaviour and had not shipped yet. `App.boot`'s JSDoc now says the helpers call it and hand-calling is for `app.fetch` / `app.upgrade` driven by your own server. The README needed nothing: it has no code example using either adapter.
Both were synchronous and left the boot to the first request, with the fix
documented as something the caller should remember: `await app.boot()` before
`Deno.serve` / `Bun.serve`. That made the correct use of a core helper depend
on reading a README, in a framework whose whole argument is that order should
not be something you have to get right.
The failure it leaves is the bad kind. `app.fetch` boots lazily and the boot
memo keeps the *rejection*, so a missing signing key does not fail the deploy:
the port binds, every request is answered 500 by the runtime, and none of them
reach `onError`. Anything that health-checks by asking whether the process is
listening sees a healthy server.
`listen()` has always awaited `bootApp()` before binding its socket, with a
comment saying it exists so Node and Deno/Bun serve an identical graph. They
did not. Now the three helpers agree, and the two adapters return promises.
`edgeHandler` is deliberately unchanged: on workerd there is no startup outside
a request, so there is no earlier moment to move the failure to.
Both new tests were confirmed to fail with the gate commented out — without it
`serveBun` resolves instead of rejecting, and serveDeno binds a port that 500s.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
chrnx
merged commit a57223cef9 into develop2026-09-20 16:55:49 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes the gap Diego spotted reading
@green-tea/jwt's README, which told the reader to callapp.boot()beforeDeno.serve/Bun.serve.That note was accurate, and that is the problem. It documented a core helper whose correct use depended on the caller remembering something — in a framework whose argument is that order should not be a thing you have to get right.
Why the old failure was the bad kind
listen()has always doneawait bootApp()before binding its socket (src/app/index.ts:328), with a comment saying it exists "so Node and Deno/Bun serve an identical graph". They did not:serveDenoandserveBunwere synchronous and left boot toapp.fetch.app.fetchboots lazily and the boot memo keeps the rejection. So a missing signing key was not a failed deploy:500by the runtimeonErrorThe change
serveDenoandserveBunareasync, returningPromise<DenoServer>andPromise<BunServeResult>. The returned value is unchanged, so migration is one keyword:Both runtimes support top-level
await, so a module that serves at import time needs nothing else. This is what the shutdown examples already do with the result, and the app still owns its own close.edgeHandleris deliberately untouched: on workerd there is no startup outside a request, so there is no earlier moment to move the failure to. That is now the only place the lazy path is documented, and there it is true.Verification
Two new integration tests, one per runtime, asserting a failing provider rejects the serve call instead of binding a port that 500s. Both confirmed to bite — with
await app.boot()commented out,serveBunresolves instead of rejecting and the Deno test reports<resolved>.deno publish --dry-runEvery call site updated: 12 test files, 2 bench servers. One Bun helper (
startTeapot) had to becomeasync, which is the only non-mechanical edit.Docs: a
### Breakingentry with the diff, and the[Unreleased]app.boot()entry rewritten — it described the old behaviour and had not shipped yet.App.boot's JSDoc now says the helpers call it and hand-calling is forapp.fetch/app.upgradedriven by your own server. The README needed nothing: it has no code example using either adapter.