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>
34 lines
1.5 KiB
TypeScript
34 lines
1.5 KiB
TypeScript
import 'reflect-metadata';
|
|
import { createApp, Step, Route, Get, Post, Module, needs, param, body } from '../../dist/index.mjs';
|
|
import { serveDeno } from '../../dist/deno.mjs';
|
|
|
|
// Same BenchModule as green-tea.ts (Node), served via Deno.serve instead of app.listen.
|
|
const emailSchema = {
|
|
'~standard': { version: 1 as const, vendor: 'bench', validate: (v: any) =>
|
|
(v && typeof v.email === 'string' && v.email.includes('@')) ? { value: v } : { issues: [{ message: 'invalid email' }] } },
|
|
};
|
|
|
|
function makeStep(n: number) {
|
|
@Step({ provides: `s${n}`, needs: n > 1 ? [`s${n - 1}`] : [] })
|
|
class S { run() { return { [`s${n}`]: n }; } }
|
|
return S;
|
|
}
|
|
const steps = [1, 2, 3, 4, 5].map(makeStep);
|
|
|
|
@Route('/')
|
|
class Bench {
|
|
@Get('/hello') hello() { return { hello: 'world' }; }
|
|
@Get('/users/:id') user(@param('id') id: string) { return { id }; }
|
|
@Get('/pipeline') pipeline(@needs('s3') s3: number) { return { hello: 'world', s3 }; }
|
|
@Post('/validate') validate(@body(emailSchema) b: any) { return { email: b.email }; }
|
|
@Get('/steps/0') steps0() { return { hello: 'world' }; }
|
|
@Get('/steps/3') steps3(@needs('s3') s3: number) { return { hello: 'world', s3 }; }
|
|
@Get('/steps/5') steps5(@needs('s5') s5: number) { return { hello: 'world', s5 }; }
|
|
}
|
|
|
|
@Module({ mountpoint: '/', steps, controllers: [Bench] })
|
|
class BenchModule {}
|
|
|
|
const app = createApp({ modules: [BenchModule], security: false });
|
|
await serveDeno(app, { port: 0, hostname: '0.0.0.0', onListen: (a: { port: number }) => console.log(`READY ${a.port}`) });
|