feat(runtime)!: serveDeno and serveBun boot before they bind
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>
This commit is contained in:
18 files changed
+147
-38
No files matched your search
@@ -23,7 +23,7 @@ const app = createApp({
|
||||
// `ready` is printed after `serveDeno` returns, not from `onListen` — Deno calls `onListen`
|
||||
// synchronously from inside `Deno.serve`, so a parent that signals on that line races the handler
|
||||
// registration that happens a few statements later and wins.
|
||||
const server = serveDeno(app, { port: 0, onListen: () => {} });
|
||||
const server = await serveDeno(app, { port: 0, onListen: () => {} });
|
||||
|
||||
console.log(JSON.stringify({ ready: true }));
|
||||
void server;
|
||||
Reference in new issue
Block a user