Author SHA1 Message Date
chrnx a16be6a832 Merge pull request 'chore(release): cut 26.9.0-beta.2' (#99) from chore/cut-26.9.0-beta.2 into develop
CI / dco (pull_request) Successful in 5s
CI / runtimes (bun) (pull_request) Successful in 16s
CI / build (pull_request) Successful in 30s
CI / runtimes (edge) (pull_request) Successful in 12s
CI / runtimes (deno) (pull_request) Successful in 20s
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 14s
CI / build (push) Successful in 32s
CI / runtimes (deno) (push) Successful in 18s
Promote → GitHub / push-github (push) Successful in 5s
CI / runtimes (edge) (push) Successful in 14s
Release → npmjs / publish-prod (push) Has been skipped
Stage → Verdaccio / publish-stg (push) Successful in 27s
2026-09-23 01:50:39 +00:00
chrnx b0a9f3bfc9 chore(release): cut 26.9.0-beta.2
CI / dco (pull_request) Successful in 7s
CI / build (pull_request) Successful in 31s
CI / runtimes (bun) (pull_request) Successful in 17s
CI / runtimes (deno) (pull_request) Successful in 20s
CI / runtimes (edge) (pull_request) Successful in 14s
Dated 2026-09-22, the day the tag goes up, rather than the day the version was
decided — package.json has said 26.9.0-beta.2 since the staging bump on the
17th, and that is the difference the heading records. A version number is a
plan; a changelog heading is a receipt.

Last commit before the tag, which is the order AGENTS.md asks for and the one
the beta.1 slip taught: everything merged, the release gate measured, the
suites green on all four runtimes, and only then the date. Held here rather
than written with the bump, so nothing accumulated underneath a heading that
claimed to have shipped it.

The section covers what landed since beta.1: the plugin contract, app.boot(),
async serveDeno/serveBun, errors recognised by brand, and the mesh moving to
steps-and-routes-only exports. `release.yml` reads this section by version to
build the GitHub release notes, and does so after npm and JSR have published,
so the heading has to exist before the tag rather than after it.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-22 20:41:19 -05:00
chrnx 9a8677d5c2 fix(bench): date the run in project time, and let the harness typecheck again
Two things the release run surfaced, neither of them visible from CI.

`npm run typecheck:bench` has been failing since serveDeno and serveBun became
async: the bench servers gained a top-level await, which `module: commonjs`
rejects outright, and bench/tsconfig.json inherited commonjs from the root
config it extends. The servers are ES modules run by tsx, Deno and Bun and
never by the CommonJS build, so the config was describing the wrong thing even
before the await arrived. CI runs `typecheck`, not `typecheck:bench`, which is
why a break in the harness waited for someone to run it by hand.

The date came from the runner's clock through toISOString, which is UTC. The
table was measured on the evening of the 22nd over ssh against a box keeping
UTC and dated itself the 23rd, a day ahead of the commit and of the changelog
entry it sits beside. It now reads project time.

tsx transpiles with this tsconfig too, so the module change was verified by
running the smoke pass again on that box: all six frameworks, the secure run
and all three runtimes still boot, and the regenerated header reads 2026-09-22.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-22 20:37:45 -05:00
chrnx 8c95ae8bfb docs(bench): regenerate the cross-framework tables on a box that was not busy
Measured on an otherwise idle Ryzen 3700X over ssh, with the same Node, Deno
and Bun versions the laptop runs, after two attempts here were thrown away.
The absolute numbers drop to roughly a third — a 2019 desktop part against an
M4 Max — and that is the trade: a slower box whose numbers mean something
beats a faster one whose numbers track what else was on screen.

The shape reproduced across both machines, which is the result worth having.
green-tea is behind Fastify on hello, param and pipeline, ahead of it on
validate, and ~2.8x ahead of Express, on the M4 and on the Ryzen alike. The
size of the gap did not reproduce (2-8% there, 7-15% here), so the README now
says the direction and points at the table for the number, rather than
quoting a percentage that is really a fact about somebody's hardware.

CV lands between 0.1% and 1.3% across every row, against 4-6% on the
contended runs.

Fixes a sentence added an hour ago claiming the ordering inside the fast group
moves between runs by more than the gap between its members. It does not — it
held on both boxes — and the claim happened to be the one that flattered us.
Cross-framework tables and the runtime table are regenerated; the hand-written
section below the marker, including the release gate, is untouched.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-22 20:20:57 -05:00
chrnx daf0fed8ab docs(agents): delete a branch when its work lands, on both sides
The cleanup that prompted this removed 36 branches from Gitea and 29 locally,
all but one already in develop and some of them three months old. Nothing had
gone wrong — each was simply merged and left, and the deletes were never part
of anyone's definition of done.

The cost lands on whoever cuts the next release, who cannot tell a branch
holding unmerged work from one that shipped in July without checking each in
turn. Writing the rule here rather than leaving it to habit is the point: the
humans and the agents working in this repository read the same file, so the
same definition of done applies to both.

CLAUDE.md is not touched on purpose — it points here precisely so the two
cannot drift.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-22 14:15:54 -05:00
chrnx c5a8361c14 docs(bench): record the 26.9.0-beta.2 release gate, and drop a claim it never supported
The breaking changes in this release — `Plugin` as `{ name, mount }`, async
`serveDeno`/`serveBun`, a teapot that cannot export a provider, an `HttpError`
recognised by brand — are boot-time and error-path work, so the question was
whether any of it reached the per-request path. Ten cases against
`v26.9.0-beta.1`, both trees on one box in one sitting with the order
alternating: nine overlap and say nothing, which is the answer.

The tenth is the part worth keeping. `param, 50 routes` came out +4.3% with
separated ranges, in our favour, and had no mechanism — the matcher work that
could produce it would have to show at 200 routes, where the same run said
+0.1%. Seven rounds put it at +0.5% and overlapping. It was chance, and it is
recorded as chance, because a flagged row means measure again in either
direction.

The README has claimed since 7 July that green-tea beat every other framework
in 3 of 4 scenarios. The table it links to stopped saying that at some point
over the following two months — a ranking written into prose once is a claim
nobody re-measures, and this one outlived the NestJS rows, the parity controls
and the runtime-neutral boundary the file itself documents the cost of. It is
replaced by the shape of the result, which is stable, and a pointer to the
table for the numbers, which are not.

The cross-framework tables are deliberately left at their 2026-09-02 date.
Two attempts to regenerate them produced runs where a framework's delta
tracked its position in the run order and a browser held ~60% of the machine;
publishing those would have read as green-tea overtaking Fastify, which is the
most flattering available reading of a broken measurement. Absolute numbers
need a quiet box.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-22 14:14:02 -05:00
chrnx a57223cef9 Merge pull request 'feat(runtime)!: serveDeno and serveBun boot before they bind' (#98) from feature/serve-adapters-boot into develop
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 16s
CI / build (push) Successful in 29s
CI / runtimes (deno) (push) Successful in 19s
CI / runtimes (edge) (push) Successful in 12s
Promote → GitHub / push-github (push) Successful in 6s
2026-09-20 16:55:47 +00:00
chrnx 9634ec73e8 feat(runtime)!: serveDeno and serveBun boot before they bind
CI / dco (pull_request) Successful in 6s
CI / build (pull_request) Successful in 30s
CI / runtimes (bun) (pull_request) Successful in 16s
CI / runtimes (deno) (pull_request) Successful in 20s
CI / runtimes (edge) (pull_request) Successful in 13s
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>
2026-09-19 12:38:50 -05:00
chrnx cbeab73626 Merge pull request 'chore(release): 26.9.0-beta.2 to staging' (#97) from release/26.9.0-beta.2 into develop
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 16s
CI / build (push) Successful in 30s
CI / runtimes (deno) (push) Successful in 19s
CI / runtimes (edge) (push) Successful in 13s
Promote → GitHub / push-github (push) Successful in 7s
2026-09-18 03:53:29 +00:00
chrnx 58ba18f9f8 chore: ignore per-developer agent directories
Stage → Verdaccio / publish-stg (push) Successful in 28s
CI / dco (pull_request) Successful in 5s
CI / runtimes (bun) (pull_request) Successful in 16s
CI / build (pull_request) Successful in 32s
CI / runtimes (deno) (pull_request) Successful in 22s
CI / runtimes (edge) (pull_request) Successful in 13s
.claude/ and .serena/ hold local settings and tool locks, one directory per
assistant, and both turned up as untracked noise in every status. Nothing in
either is shared configuration — .serena/ ships its own .gitignore, and the
only .claude/ file with a stable name is settings.local.json.

Blanket-ignored rather than enumerated, with a comment naming the one case that
would need revisiting: a repository-wide .claude/settings.json is a real
convention, and committing one later takes a negation line here. No such file
exists today, so this does not pre-build a rule for it.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-17 22:40:03 -05:00
chrnx a30c2cecb3 chore(release): 26.9.0-beta.2 to staging
The plugins repository builds against Plugin { name, mount } and app.boot(),
which only develop has. Staging the version publishes it to Verdaccio under
stg and nowhere else; the npm and JSR cut stays a separate decision.

The bump also moves the exported VERSION, which was two releases behind and had
no business being. Its comment claimed it was "replaced at publish time" and
nothing ever did that — not tsup, not stage.yml, not release.yml, which only
reads the version out of package.json. VERSION is what a consumer quotes in a
bug report, so a stale one sends someone to the changelog of a release they are
not running.

Pinning it to package.json is what keeps this from being a fix with a shelf
life: the next bump that forgets it now fails the build. smoke.test.ts was
never going to catch it, because it asserts the CalVer shape and a stale
version matches that perfectly.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-09-17 22:39:49 -05:00
30 changed files with 517 additions and 304 deletions

No files matched your search

+7
View File
@@ -1,6 +1,13 @@
# Local specs & plans — not committed # Local specs & plans — not committed
.specs/ .specs/
# Per-developer agent state: local settings and tool locks, one directory per assistant. Nothing
# here is shared configuration — `.serena/` even ships its own .gitignore. A repository-wide
# `.claude/settings.json` is a real convention and would need a `!` line here to be committable;
# none exists today, so this stays a blanket ignore rather than a rule for a file nobody wrote.
.claude/
.serena/
# Node # Node
node_modules/ node_modules/
dist/ dist/
+8
View File
@@ -55,6 +55,14 @@ feature/* → develop → main → [promote.yml] → GitHub main
**Only `hotfix/*` can still cause real drift**, since it branches from and returns to `main`. That case genuinely needs a back-merge; nothing else does. **Only `hotfix/*` can still cause real drift**, since it branches from and returns to `main`. That case genuinely needs a back-merge; nothing else does.
**Delete the branch when the work lands.** Both sides, as the last step of merging rather than a chore left for later:
```bash
git branch -d <branch> && git push origin --delete <branch>
```
On 2026-09-22 this repository carried 36 branches on Gitea and 29 locally, every one but a single stale docs branch already merged into `develop`, some of them since July. At that size the branch list stops describing the work in flight and becomes something a release has to audit commit by commit — which is both when it costs the most and when nobody has the patience for it. `git branch -r --merged origin/develop` is the check. A branch whose commits were rebased on the way in will not appear there even though its content did land, so confirm that case by content (`git diff <branch> develop -- <file>`) rather than by the flag. Never `develop`, `main`, or a `release/*` that has not shipped yet.
**Diagnosing "this branch is ahead of main".** Usually it is pre-rebase duplication, not unmerged work: the same content under different SHAs, because contributions are rebased on their way into `develop`. Confirm before acting: **Diagnosing "this branch is ahead of main".** Usually it is pre-rebase duplication, not unmerged work: the same content under different SHAs, because contributions are rebased on their way into `develop`. Confirm before acting:
```bash ```bash
+90 -40
View File
@@ -4,12 +4,12 @@
## Environment ## Environment
- **Date**: 2026-09-02 - **Date**: 2026-09-22
- **Commit**: 8c5855c - **Commit**: daf0fed
- **Node**: v22.22.2 - **Node**: v22.22.2
- **OS**: darwin - **OS**: linux
- **CPU**: Apple M4 Max (16 cores) - **CPU**: AMD Ryzen 7 3700X 8-Core Processor (16 cores)
- **RAM**: 69 GB - **RAM**: 67 GB
- **Core-pinned**: no - **Core-pinned**: no
- **autocannon config**: 100 connections, 10s duration, 5 runs (1 warmup discarded), pipelining 1 - **autocannon config**: 100 connections, 10s duration, 5 runs (1 warmup discarded), pipelining 1
@@ -29,74 +29,74 @@
| Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s | | Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s |
| --- | --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- | --- |
| raw-http | 119,357 | 0.00 | 1.00 | 1.00 | 0.4% | 118,560–120,067 | | raw-http | 41,631 | 2.00 | 3.00 | 4.00 | 0.6% | 41,343–41,974 |
| nestjs-fastify | 98,039 | 0.00 | 1.00 | 2.00 | 1.2% | 96,073–99,680 | | nestjs-fastify | 32,419 | 3.00 | 4.00 | 6.00 | 0.5% | 32,103–32,583 |
| fastify | 89,097 | 1.00 | 1.00 | 2.00 | 0.1% | 88,864–89,207 | | fastify | 32,170 | 3.00 | 3.00 | 5.00 | 1.3% | 31,236–32,356 |
| green-tea | 87,473 | 1.00 | 2.00 | 2.00 | 0.3% | 86,903–87,607 | | green-tea | 29,777 | 3.00 | 6.00 | 7.00 | 0.4% | 29,557–29,873 |
| express | 24,677 | 3.00 | 5.00 | 8.00 | 0.2% | 24,647–24,769 | | express | 10,546 | 8.00 | 13.00 | 18.00 | 0.4% | 10,480–10,625 |
| nestjs-express | 21,879 | 4.00 | 6.00 | 9.00 | 0.2% | 21,845–21,953 | | nestjs-express | 9,680 | 9.00 | 15.00 | 21.00 | 0.6% | 9,567–9,739 |
### Route param ### Route param
| Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s | | Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s |
| --- | --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- | --- |
| raw-http | 120,905 | 0.00 | 1.00 | 1.00 | 0.5% | 119,927–121,713 | | raw-http | 41,756 | 2.00 | 3.00 | 4.00 | 1.1% | 40,953–42,017 |
| nestjs-fastify | 91,849 | 1.00 | 1.00 | 2.00 | 0.3% | 91,825–92,599 | | fastify | 31,708 | 3.00 | 4.00 | 5.00 | 0.5% | 31,359–31,847 |
| fastify | 88,317 | 1.00 | 1.00 | 2.00 | 0.2% | 87,997–88,439 | | nestjs-fastify | 29,880 | 3.00 | 4.00 | 6.00 | 0.3% | 29,745–29,961 |
| green-tea | 86,595 | 1.00 | 2.00 | 2.00 | 0.2% | 86,368–86,880 | | green-tea | 28,706 | 3.00 | 6.00 | 7.00 | 0.6% | 28,562–29,051 |
| express | 24,200 | 3.00 | 5.00 | 8.00 | 0.2% | 24,158–24,260 | | express | 10,376 | 9.00 | 12.00 | 17.00 | 0.4% | 10,364–10,453 |
| nestjs-express | 21,182 | 4.00 | 6.00 | 9.00 | 0.7% | 21,150–21,518 | | nestjs-express | 9,257 | 10.00 | 15.00 | 21.00 | 0.2% | 9,244–9,285 |
### Pipeline (3 steps) (approximation) ### Pipeline (3 steps) (approximation)
| Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s | | Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s |
| --- | --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- | --- |
| raw-http | 118,996 | 0.00 | 1.00 | 1.00 | 0.3% | 118,583–119,584 | | raw-http | 39,897 | 2.00 | 3.00 | 5.00 | 0.6% | 39,847–40,441 |
| nestjs-fastify | 89,527 | 1.00 | 2.00 | 2.00 | 1.0% | 87,572–90,028 | | fastify | 31,436 | 3.00 | 4.00 | 6.00 | 0.6% | 31,079–31,563 |
| fastify | 86,671 | 1.00 | 1.00 | 2.00 | 0.1% | 86,490–86,793 | | nestjs-fastify | 29,403 | 3.00 | 4.00 | 6.00 | 0.6% | 29,151–29,689 |
| green-tea | 80,079 | 1.00 | 2.00 | 2.00 | 0.2% | 80,026–80,375 | | green-tea | 26,839 | 3.00 | 6.00 | 8.00 | 0.1% | 26,783–26,872 |
| express | 24,325 | 3.00 | 5.00 | 8.00 | 0.2% | 24,281–24,407 | | express | 10,365 | 9.00 | 12.00 | 18.00 | 1.3% | 10,171–10,542 |
| nestjs-express | 20,872 | 4.00 | 6.00 | 9.00 | 0.2% | 20,801–20,940 | | nestjs-express | 9,256 | 10.00 | 15.00 | 22.00 | 0.5% | 9,187–9,302 |
### POST JSON + validation ### POST JSON + validation
| Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s | | Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s |
| --- | --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- | --- |
| raw-http | 104,288 | 0.00 | 1.00 | 1.00 | 0.4% | 103,776–104,916 | | raw-http | 31,783 | 3.00 | 5.00 | 6.00 | 0.4% | 31,517–31,825 |
| green-tea | 70,298 | 1.00 | 2.00 | 3.00 | 1.0% | 68,972–70,607 | | green-tea | 22,005 | 4.00 | 7.00 | 9.00 | 0.7% | 21,736–22,187 |
| fastify | 65,905 | 1.00 | 2.00 | 3.00 | 0.3% | 65,725–66,367 | | fastify | 20,430 | 4.00 | 8.00 | 9.00 | 0.4% | 20,398–20,601 |
| nestjs-fastify | 63,318 | 1.00 | 2.00 | 3.00 | 0.9% | 62,454–63,747 | | nestjs-fastify | 18,597 | 4.00 | 8.00 | 11.00 | 0.2% | 18,540–18,658 |
| express | 20,297 | 4.00 | 6.00 | 10.00 | 0.5% | 20,158–20,414 | | express | 8,440 | 11.00 | 16.00 | 24.00 | 0.3% | 8,408–8,492 |
| nestjs-express | 18,788 | 5.00 | 7.00 | 10.00 | 0.3% | 18,684–18,862 | | nestjs-express | 7,666 | 12.00 | 18.00 | 26.00 | 0.3% | 7,645–7,703 |
## Step-scaling (green-tea) ## Step-scaling (green-tea)
| Path | Steps | req/s | | Path | Steps | req/s |
| --- | --- | --- | | --- | --- | --- |
| /steps/0 | 0 | 88,108 | | /steps/0 | 0 | 29,196 |
| /steps/3 | 3 | 79,951 | | /steps/3 | 3 | 26,564 |
| /steps/5 | 5 | 74,127 | | /steps/5 | 5 | 25,314 |
Each additional pipeline step costs roughly 2,796 req/s (-15.9% over 5 steps), on this box. Each additional pipeline step costs roughly 776 req/s (-13.3% over 5 steps), on this box.
## green-tea across runtimes ## green-tea across runtimes
| Scenario | node | deno | bun | | Scenario | node | deno | bun |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| JSON hello (overhead) | 90,976 | 153,408 | 131,674 | | JSON hello (overhead) | 30,379 | 51,888 | 46,300 |
| Route param | 88,905 | 146,368 | 126,909 | | Route param | 29,204 | 51,786 | 42,788 |
| Pipeline (3 steps) | 82,045 | 136,256 | 117,489 | | Pipeline (3 steps) | 27,208 | 50,692 | 39,644 |
| POST JSON + validation | 72,236 | 106,662 | 95,124 | | POST JSON + validation | 22,609 | 35,743 | 31,960 |
Same application, same built bundle, same box — only the runtime differs. Read across a row, never against the cross-framework tables above: those measure other frameworks on Node, and nobody ran fastify on Bun here. A runtime that is not installed is absent rather than zero. Same application, same built bundle, same box — only the runtime differs. Read across a row, never against the cross-framework tables above: those measure other frameworks on Node, and nobody ran fastify on Bun here. A runtime that is not installed is absent rather than zero.
## Cost of secure-by-default (green-tea) ## Cost of secure-by-default (green-tea)
| Label | req/s | | Label | req/s |
| --- | --- | | --- | --- |
| security:false (parity) | 87,473 | | security:false (parity) | 29,777 |
| security:true (default) | 83,773 | | security:true (default) | 28,919 |
The real cost of running secure-by-default (rather than the parity-mode `security:false` used above) is ~4.2% req/s on this box. The real cost of running secure-by-default (rather than the parity-mode `security:false` used above) is ~2.9% req/s on this box.
> Scope: this micro-bench currently measures the security-**headers** cost only (`security:false` vs > Scope: this micro-bench currently measures the security-**headers** cost only (`security:false` vs
> `security:true` on `/hello`). The incremental cost of `@body` validation and CORS is not separately > `security:true` on `/hello`). The incremental cost of `@body` validation and CORS is not separately
@@ -136,6 +136,56 @@ was benchmarked as it landed — the numbers are still in the code, cited below
file between `26.7` and `26.9`, so nothing added them up. That is the gap this section and file between `26.7` and `26.9`, so nothing added them up. That is the gap this section and
`npm run bench:compare` exist to close. `npm run bench:compare` exist to close.
### The release gate: `26.9.0-beta.1` → `26.9.0-beta.2`
Ten cases, both trees on one box in one sitting, alternating which side ran first each round, sharing
one `node_modules` — the two revisions differ by a version string and nothing else in `package.json`,
so the only thing that moved between the sides is green-tea. Medians of three rounds:
| Scenario | 26.9.0-beta.1 | 26.9.0-beta.2 | Δ | |
| --- | --- | --- | --- | --- |
| hello | 90,615 | 89,853 | −0.8% | overlaps |
| param | 86,956 | 87,572 | +0.7% | overlaps |
| pipeline (3 steps) | 80,061 | 81,504 | +1.8% | overlaps |
| steps5 | 75,436 | 75,238 | −0.3% | overlaps |
| validate (POST) | 70,240 | 73,568 | +4.7% | overlaps |
| hello + security | 83,738 | 84,890 | +1.4% | overlaps |
| hello + cors predicate | 82,237 | 82,528 | +0.4% | overlaps |
| preflight + cors predicate | 111,223 | 114,220 | +2.7% | overlaps |
| param, 50 routes | 83,505 | 87,078 | +4.3% | **flagged** |
| param, 200 routes | 73,289 | 73,335 | +0.1% | overlaps |
Nine rows overlap and therefore say nothing, which is the result this gate exists to produce. The
release is a breaking one — `Plugin` became `{ name, mount }`, `serveDeno()` and `serveBun()` became
async, `@Provider({ export: true })` stopped being a thing a teapot can do, and an `HttpError` is now
recognised by a brand rather than by `instanceof` — but all of that is boot-time or error-path work.
None of it sits on the per-request path these cases walk, and the table agrees.
The tenth row is why "flagged" is not a synonym for "found something". `param, 50 routes` came out
+4.3% with separated ranges, in green-tea's favour, and it did not survive being asked twice: re-run
alone at seven rounds it is **+0.5% and overlapping**, with both sides swinging between 80,794 and
88,259 req/s. The reason to doubt it before re-running was that it had no mechanism — the matcher
work that could produce it would have to show at 200 routes too, and that row had already said
+0.1%. Treat a flagged row as an instruction to measure again, whichever direction it points; a win
nobody can explain is a measurement problem more often than it is a win.
The cross-framework tables above moved to a quiet box for this release, which is why their absolute
numbers are roughly a third of the previous run's: an idle 2019 desktop Ryzen against a laptop M4
Max. Two attempts on that laptop were discarded first, and the reason is worth recording. Each
framework's delta against its own previous number tracked its position in the run order rather than
anything in its code — the one measured second lost 7%, the ones measured last gained — while a
browser and the window server held around 60% of the machine throughout. That run would have read
as green-tea overtaking Fastify, which is the most flattering available reading of a broken
measurement and exactly the kind this file exists to refuse. The gate table above survives the same
contention, because both sides pay it and the order alternates; an absolute cross-framework number
does not.
What survived the move is the shape, and that is the part worth trusting. On both machines green-tea
is behind Fastify on `hello`, `param` and `pipeline` and ahead of it on `validate`, and roughly
2.8× ahead of Express throughout. The *size* of the gap did not survive: against Fastify it is
2-8% on the M4 and 7-15% here. A percentage quoted without the hardware it was measured on is not a
fact about the framework.
### The release gate: `26.8.0-beta.1` → `26.9.0-beta.1` ### The release gate: `26.8.0-beta.1` → `26.9.0-beta.1`
Both trees measured on one box in one sitting, alternating which side ran first each round, sharing Both trees measured on one box in one sitting, alternating which side ran first each round, sharing
+29 -6
View File
@@ -6,10 +6,32 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
green-tea uses calendar versioning: `YY.M.PATCH` — the month is not zero-padded, since green-tea uses calendar versioning: `YY.M.PATCH` — the month is not zero-padded, since
npm treats versions as semver and semver forbids leading zeros. npm treats versions as semver and semver forbids leading zeros.
## [Unreleased] ## [26.9.0-beta.2] - 2026-09-22
### Breaking ### Breaking
- **`serveDeno()` and `serveBun()` are async**, returning `Promise<DenoServer>` and
`Promise<BunServeResult>`. They now boot the app before they bind, which is what `listen()` has
always done.
They did not, and the documented fix was to remember to `await app.boot()` first. That made the
correct use of a core helper depend on reading a README, in a framework whose argument is that
order should not be something you have to get right. Forget it and a missing signing key is not a
failed deploy: the boot memo keeps the rejection, so the port binds, every request gets a 500 from
the runtime, and none of them reach `onError`. The server looks healthy to anything that only
checks whether it is listening.
Migration is one keyword, and the value is unchanged:
```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. `edgeHandler` is deliberately untouched: on workerd there is no startup outside a request,
so there is no earlier moment to move the failure to.
- **A plugin is a named object.** `Plugin` is now `{ name, mount(api) }`; it was `(api) => void`. - **A plugin is a named object.** `Plugin` is now `{ name, mount(api) }`; it was `(api) => void`.
The name that `plugin:mounted` reports came from `fn.name`, which is `""` for an arrow returned The name that `plugin:mounted` reports came from `fn.name`, which is `""` for an arrow returned
straight from a factory, `"plugin"` for a `const`, and whatever a minifier leaves behind — so the straight from a factory, `"plugin"` for a `const`, and whatever a minifier leaves behind — so the
@@ -57,11 +79,11 @@ npm treats versions as semver and semver forbids leading zeros.
### Added ### Added
- **`app.boot()`** runs the provider factories now instead of on the first request. `listen()` - **`app.boot()`** runs the provider factories now instead of on the first request. `listen()`,
always did this; `app.fetch`, `serveDeno`, `serveBun` and `edgeHandler` boot lazily, and the boot `serveDeno()` and `serveBun()` all call it for you (see Breaking, below). Call it by hand when you
memo keeps a rejection — so a bad key answered 500 on *every* request, from the runtime, without drive `app.fetch` / `app.upgrade` from your own server: those boot lazily, and the boot memo keeps
reaching `onError`. `await app.boot()` before `Deno.serve`/`Bun.serve` turns that into a startup a rejection, so a bad key answers 500 on *every* request, from the runtime, without reaching
failure. On workerd there is no startup outside a request, so calling it moves nothing. `onError`. On workerd there is no startup outside a request, so calling it moves nothing.
- **Errors are recognised by brand.** `HttpError` and `ValidationError` now carry - **Errors are recognised by brand.** `HttpError` and `ValidationError` now carry
`Symbol.for('green-tea.http-error')` and `Symbol.for('green-tea.validation-error')`, and `Symbol.for('green-tea.http-error')` and `Symbol.for('green-tea.validation-error')`, and
`isHttpError` checks the brand instead of `instanceof`. An error thrown by code holding a `isHttpError` checks the brand instead of `instanceof`. An error thrown by code holding a
@@ -620,6 +642,7 @@ change before the stable release.
- **Benchmarks** — reproducible `npm run bench` harness vs Express 5, Fastify 5, - **Benchmarks** — reproducible `npm run bench` harness vs Express 5, Fastify 5,
NestJS, and raw `http`; results in [BENCHMARKS.md](./BENCHMARKS.md). NestJS, and raw `http`; results in [BENCHMARKS.md](./BENCHMARKS.md).
[26.9.0-beta.2]: https://github.com/Expressive-Tea/green-tea/compare/v26.9.0-beta.1...v26.9.0-beta.2
[26.9.0-beta.1]: https://github.com/Expressive-Tea/green-tea/compare/v26.8.0-beta.1...v26.9.0-beta.1 [26.9.0-beta.1]: https://github.com/Expressive-Tea/green-tea/compare/v26.8.0-beta.1...v26.9.0-beta.1
[26.8.0-beta.1]: https://github.com/Expressive-Tea/green-tea/compare/v26.8.0-beta.0...v26.8.0-beta.1 [26.8.0-beta.1]: https://github.com/Expressive-Tea/green-tea/compare/v26.8.0-beta.0...v26.8.0-beta.1
[26.8.0-beta.0]: https://github.com/Expressive-Tea/green-tea/compare/v26.7.0-beta.0...v26.8.0-beta.0 [26.8.0-beta.0]: https://github.com/Expressive-Tea/green-tea/compare/v26.7.0-beta.0...v26.8.0-beta.0
+5 -3
View File
@@ -56,7 +56,7 @@ npm install busboy # multipart/form-data file uploads
- **The type is the contract.** What a handler reads from the context *is* its dependency list. In the typed `flow` core, a handler that reads `ctx.user` **fails to compile** if no step produces `user`. *Why it matters:* whole classes of "it was undefined in prod" disappear at compile time. - **The type is the contract.** What a handler reads from the context *is* its dependency list. In the typed `flow` core, a handler that reads `ctx.user` **fails to compile** if no step produces `user`. *Why it matters:* whole classes of "it was undefined in prod" disappear at compile time.
- **You can see the request before it runs.** `app.explain('/users/:id')` prints the ordered chain with origins; `app.graph()` / `GET /__graph__` render it as a live diagram; `app.openapi()` projects the same metadata into an OpenAPI 3.1 spec. *Why it matters:* onboarding, debugging, audits, and API docs are reading, not archaeology. (NestJS puts the graph behind a paid Devtools plan.) - **You can see the request before it runs.** `app.explain('/users/:id')` prints the ordered chain with origins; `app.graph()` / `GET /__graph__` render it as a live diagram; `app.openapi()` projects the same metadata into an OpenAPI 3.1 spec. *Why it matters:* onboarding, debugging, audits, and API docs are reading, not archaeology. (NestJS puts the graph behind a paid Devtools plan.)
- **One primitive for real-time.** Declare the transport — SSE, ndjson, or a WebSocket duplex — and return an `AsyncIterable`; backpressure and cleanup are handled. *Why it matters:* no separate gateway, adapter, or library to bolt on. - **One primitive for real-time.** Declare the transport — SSE, ndjson, or a WebSocket duplex — and return an `AsyncIterable`; backpressure and cleanup are handled. *Why it matters:* no separate gateway, adapter, or library to bolt on.
- **The same app runs on Node, Deno, Bun, and the edge.** One codebase, one import; you swap the entry point (`app.listen` → `serveDeno` / `serveBun` / `edgeHandler`) and nothing else. HTTP, SSE, and WebSocket — including rooms and channels — behave identically on all four. *Why it matters:* the graph model isn't a bet on one runtime's future, and no other opinionated/DI framework runs everywhere. - **The same app runs on Node, Deno, Bun, and the edge.** One codebase, one import; you swap the entry point (`await app.listen()` → `await serveDeno()` / `await serveBun()` / `edgeHandler`) and nothing else — each one boots the app before it binds, so a provider that cannot start fails the deploy instead of answering `500`s from a port that looks healthy. HTTP, SSE, and WebSocket — including rooms and channels — behave identically on all four. *Why it matters:* the graph model isn't a bet on one runtime's future, and no other opinionated/DI framework runs everywhere.
- **A remote dependency looks like a local one.** `@needs('billing')` resolves the same whether `billing` lives in this process or on another node (mesh, experimental). *Why it matters:* no gRPC layer or message-pattern DSL to learn — there's the graph, and some nodes happen to live elsewhere. - **A remote dependency looks like a local one.** `@needs('billing')` resolves the same whether `billing` lives in this process or on another node (mesh, experimental). *Why it matters:* no gRPC layer or message-pattern DSL to learn — there's the graph, and some nodes happen to live elsewhere.
- **Plugins can't sabotage you.** A plugin is `{ name, mount(api) }`. It gets `bus.on(...)` (observe), `scope.add(...)` (extend its own scope) and `onShutdown(...)` (release what it opened). There is no API to reorder or delete another scope's steps. *Why it matters:* installing a plugin can't break your body parser. - **Plugins can't sabotage you.** A plugin is `{ name, mount(api) }`. It gets `bus.on(...)` (observe), `scope.add(...)` (extend its own scope) and `onShutdown(...)` (release what it opened). There is no API to reorder or delete another scope's steps. *Why it matters:* installing a plugin can't break your body parser.
@@ -153,7 +153,9 @@ without growing the runtime dependency tree past `reflect-metadata`:
We built a reproducible [autocannon harness](./BENCHMARKS.md) comparing green-tea to Express 5, Fastify 5, NestJS (on both Express and Fastify), and raw Node `http` — and we wrote it to be **hard on ourselves**, not flattering. We built a reproducible [autocannon harness](./BENCHMARKS.md) comparing green-tea to Express 5, Fastify 5, NestJS (on both Express and Fastify), and raw Node `http` — and we wrote it to be **hard on ourselves**, not flattering.
On that harness, **green-tea handled more requests per second than every other framework in 3 of 4 scenarios** (JSON response, routing, and body-parsing-plus-validation), behind only raw `http` with no framework at all. In the fourth (a multi-step pipeline) it lands even with Fastify. On that harness green-tea is in the same class as Fastify and NestJS-on-Fastify, roughly 2.8× ahead of Express, and behind raw `http` with no framework at all. Within that class the shape reproduces on two very different machines: green-tea is **behind** Fastify on the JSON, routing and pipeline scenarios, and **ahead** of it on POST-plus-validation. How far behind is a property of the box rather than a constant — 2-8% on a laptop M4 Max, 7-15% on an idle desktop Ryzen — which is why the table carries its hardware and its date, and why a percentage quoted without them says little. Read [BENCHMARKS.md](./BENCHMARKS.md) rather than a sentence here: a ranking written into prose once is a claim nobody re-measures.
The question a release actually has to pass is the other one — *did the last N commits cost anything* — and comparing today's numbers against a table generated weeks ago answers it with two machines in a mood rather than two versions. `npm run bench:compare` runs both trees on one box in one sitting, alternating sides; `26.9.0-beta.1 → 26.9.0-beta.2` came out flat on every case.
Read the honest caveats in [BENCHMARKS.md](./BENCHMARKS.md): the numbers are single-box + loopback (absolute throughput is overstated and differences compressed — trust the *ratios*), the cross-framework table runs green-tea with `security:false` for header parity, and the real cost of secure-by-default is measured separately. Regenerate any time with `npm run bench`. Read the honest caveats in [BENCHMARKS.md](./BENCHMARKS.md): the numbers are single-box + loopback (absolute throughput is overstated and differences compressed — trust the *ratios*), the cross-framework table runs green-tea with `security:false` for header parity, and the real cost of secure-by-default is measured separately. Regenerate any time with `npm run bench`.
@@ -288,7 +290,7 @@ green-tea is **beta**, on the road to a release candidate. Express and Fastify h
**What a teapot exports: steps and routes, and nothing else.** A `@Provider` marked `export: true` fails the boot with an error that says why — a provider's value *is* the object it builds, a pool or a client or a `db`, and the mesh moves data, not objects. Export a `@Step` instead: it runs on the teapot, per request, and its result is what comes back. That is also what lets a teacup boot without its teapot: a remote step holds nothing between requests, so a teacup whose teapot never answers still starts once the `bootTimeoutMs` grace runs out — it warns and carries on. Be precise about what that means, because it is narrower than it sounds. A teapot that never connected sent no manifest, so nothing of it reached the graph: its routes **404** rather than `503`, since nothing was registered to match, and a local step that `@needs` one of its tokens **still fails the boot**, naming the teapot that did not connect. That failure is deliberate — it is the check that catches a typo in a token name, which no amount of waiting will fix. `503` is what you get from a teapot that connected and *later* died, where the link and its exports do exist. So what the change buys is the teacup that does *not* depend on that teapot starting anyway, rather than refusing over a dependency it never had. Keeping a *needed* token serving while its teapot is legitimately away is a known gap, not an oversight: the intended answer is the `expects` list in [the mesh degrade plan](./docs/plans/2026-08-18-mesh-degrade-plan.md), which is planned and not built. **What a teapot exports: steps and routes, and nothing else.** A `@Provider` marked `export: true` fails the boot with an error that says why — a provider's value *is* the object it builds, a pool or a client or a `db`, and the mesh moves data, not objects. Export a `@Step` instead: it runs on the teapot, per request, and its result is what comes back. That is also what lets a teacup boot without its teapot: a remote step holds nothing between requests, so a teacup whose teapot never answers still starts once the `bootTimeoutMs` grace runs out — it warns and carries on. Be precise about what that means, because it is narrower than it sounds. A teapot that never connected sent no manifest, so nothing of it reached the graph: its routes **404** rather than `503`, since nothing was registered to match, and a local step that `@needs` one of its tokens **still fails the boot**, naming the teapot that did not connect. That failure is deliberate — it is the check that catches a typo in a token name, which no amount of waiting will fix. `503` is what you get from a teapot that connected and *later* died, where the link and its exports do exist. So what the change buys is the teacup that does *not* depend on that teapot starting anyway, rather than refusing over a dependency it never had. Keeping a *needed* token serving while its teapot is legitimately away is a known gap, not an oversight: the intended answer is the `expects` list in [the mesh degrade plan](./docs/plans/2026-08-18-mesh-degrade-plan.md), which is planned and not built.
**What is settled, and what is still moving.** Present state, not a roadmap and not the API freeze — this is spare-time work by one person, and a schedule it cannot keep would cost more than it earns. The **graph is the settled part**: `needs`/`provides`, the order derived from them, and the boot-time failure when nothing provides a key have not changed since the beta hardening on 7 July, and `@Provider`, `@Step`, `@Route` and handler shapes still mean what they meant then — the decorator *set* has grown (`@Head`, `@Options`, `@Html`), which only ever adds. **Still moving:** the plugin API, which became `{ name, mount }` and gained `onShutdown`; `createApp`'s options, which gain fields most months; and the pipeline context, which in July became one object mutated in place rather than copied per step — so a step that captured it now sees later steps' writes. **Alpha:** mesh, above. Legacy decorators are a standing *external* risk rather than a green-tea one — see [Why legacy decorators](#why-legacy-decorators). The [matcha](https://github.com/Expressive-Tea/matcha) CLI ships from its own repository on its own version line, so nothing here speaks for it. **What is settled, and what is still moving.** Present state, not a roadmap and not the API freeze — this is spare-time work by one person, and a schedule it cannot keep would cost more than it earns. The **graph is the settled part**: `needs`/`provides`, the order derived from them, and the boot-time failure when nothing provides a key have not changed since the beta hardening on 7 July, and `@Provider`, `@Step`, `@Route` and handler shapes still mean what they meant then — the decorator *set* has grown (`@Head`, `@Options`, `@Html`), which only ever adds. **Still moving:** the plugin API, which became `{ name, mount }` and gained `onShutdown`; the runtime entry points, where `serveDeno()` and `serveBun()` became async so they boot before they bind; `createApp`'s options, which gain fields most months; and the pipeline context, which in July became one object mutated in place rather than copied per step — so a step that captured it now sees later steps' writes. **Alpha:** mesh, above. Legacy decorators are a standing *external* risk rather than a green-tea one — see [Why legacy decorators](#why-legacy-decorators). The [matcha](https://github.com/Expressive-Tea/matcha) CLI ships from its own repository on its own version line, so nothing here speaks for it.
## Docs & development ## Docs & development
+214 -214
View File
@@ -1,11 +1,11 @@
{ {
"env": { "env": {
"date": "2026-09-02", "date": "2026-09-22",
"commit": "8c5855c", "commit": "daf0fed",
"node": "v22.22.2", "node": "v22.22.2",
"os": "darwin", "os": "linux",
"cpu": "Apple M4 Max (16 cores)", "cpu": "AMD Ryzen 7 3700X 8-Core Processor (16 cores)",
"ram": "69 GB", "ram": "67 GB",
"pinned": false "pinned": false
}, },
"config": { "config": {
@@ -23,80 +23,80 @@
{ {
"framework": "raw-http", "framework": "raw-http",
"reqSec": { "reqSec": {
"median": 119357.1, "median": 41630.55,
"min": 118560, "min": 41342.55,
"max": 120066.91, "max": 41973.82,
"stddev": 484.9030139151553, "stddev": 232.79156158245826,
"cv": 0.0040636145553490976 "cv": 0.0055977118567263305
}, },
"p50": 0, "p50": 2,
"p99": 1, "p99": 3,
"p999": 1 "p999": 4
}, },
{ {
"framework": "fastify", "framework": "fastify",
"reqSec": { "reqSec": {
"median": 89096.73, "median": 32170.19,
"min": 88864, "min": 31235.64,
"max": 89207.28, "max": 32355.64,
"stddev": 111.97759400880093, "stddev": 403.36620390905324,
"cv": 0.001257219726589825 "cv": 0.012593571579786219
}, },
"p50": 1, "p50": 3,
"p99": 1, "p99": 3,
"p999": 2 "p999": 5
}, },
{ {
"framework": "express", "framework": "express",
"reqSec": { "reqSec": {
"median": 24677.1, "median": 10545.82,
"min": 24646.55, "min": 10480.37,
"max": 24768.73, "max": 10625.1,
"stddev": 43.02015834466458, "stddev": 47.02831087759791,
"cv": 0.0017417832565876405 "cv": 0.004456044641032285
}, },
"p50": 3, "p50": 8,
"p99": 5, "p99": 13,
"p999": 8 "p999": 18
}, },
{ {
"framework": "green-tea", "framework": "green-tea",
"reqSec": { "reqSec": {
"median": 87473.46, "median": 29776.73,
"min": 86903.28, "min": 29557.1,
"max": 87607.28, "max": 29872.73,
"stddev": 280.84365746087286, "stddev": 120.92248317000461,
"cv": 0.0032155347907296527 "cv": 0.004066812850878315
}, },
"p50": 1, "p50": 3,
"p99": 2, "p99": 6,
"p999": 2 "p999": 7
}, },
{ {
"framework": "nestjs-express", "framework": "nestjs-express",
"reqSec": { "reqSec": {
"median": 21878.55, "median": 9679.64,
"min": 21845.1, "min": 9566.91,
"max": 21952.73, "max": 9738.55,
"stddev": 41.00873789816055, "stddev": 58.2951632985104,
"cv": 0.0018731606009975037 "cv": 0.006025529205104781
}, },
"p50": 4, "p50": 9,
"p99": 6, "p99": 15,
"p999": 9 "p999": 21
}, },
{ {
"framework": "nestjs-fastify", "framework": "nestjs-fastify",
"reqSec": { "reqSec": {
"median": 98039.28, "median": 32418.91,
"min": 96072.73, "min": 32103.28,
"max": 99680, "max": 32582.55,
"stddev": 1215.4038343760499, "stddev": 159.574135748874,
"cv": 0.012396669934655963 "cv": 0.004929287112917938
}, },
"p50": 0, "p50": 3,
"p99": 1, "p99": 4,
"p999": 2 "p999": 6
} }
] ]
}, },
@@ -107,80 +107,80 @@
{ {
"framework": "raw-http", "framework": "raw-http",
"reqSec": { "reqSec": {
"median": 120904.73, "median": 41755.64,
"min": 119927.28, "min": 40952.73,
"max": 121713.46, "max": 42017.46,
"stddev": 658.0250991747977, "stddev": 439.72294183496837,
"cv": 0.005441723483024015 "cv": 0.010587809774433589
}, },
"p50": 0, "p50": 2,
"p99": 1, "p99": 3,
"p999": 1 "p999": 4
}, },
{ {
"framework": "fastify", "framework": "fastify",
"reqSec": { "reqSec": {
"median": 88317.1, "median": 31708.37,
"min": 87997.1, "min": 31359.28,
"max": 88439.28, "max": 31846.55,
"stddev": 182.99174422907566, "stddev": 168.73300179869975,
"cv": 0.00207430857941761 "cv": 0.005328784944282288
}, },
"p50": 1, "p50": 3,
"p99": 1, "p99": 4,
"p999": 2 "p999": 5
}, },
{ {
"framework": "express", "framework": "express",
"reqSec": { "reqSec": {
"median": 24200, "median": 10375.64,
"min": 24157.82, "min": 10364,
"max": 24259.64, "max": 10452.73,
"stddev": 39.43298619176589, "stddev": 37.668132419858544,
"cv": 0.0016290899720752198 "cv": 0.003621859193349617
}, },
"p50": 3, "p50": 9,
"p99": 5, "p99": 12,
"p999": 8 "p999": 17
}, },
{ {
"framework": "green-tea", "framework": "green-tea",
"reqSec": { "reqSec": {
"median": 86594.91, "median": 28706.19,
"min": 86368, "min": 28562.19,
"max": 86880, "max": 29050.91,
"stddev": 179.11650003279965, "stddev": 166.92265315408858,
"cv": 0.002068552609808656 "cv": 0.005803163694455583
}, },
"p50": 1, "p50": 3,
"p99": 2, "p99": 6,
"p999": 2 "p999": 7
}, },
{ {
"framework": "nestjs-express", "framework": "nestjs-express",
"reqSec": { "reqSec": {
"median": 21181.82, "median": 9257.1,
"min": 21149.82, "min": 9244,
"max": 21517.82, "max": 9285.46,
"stddev": 139.0670808494951, "stddev": 16.97885461390117,
"cv": 0.006540068168697097 "cv": 0.0018327336012062287
}, },
"p50": 4, "p50": 10,
"p99": 6, "p99": 15,
"p999": 9 "p999": 21
}, },
{ {
"framework": "nestjs-fastify", "framework": "nestjs-fastify",
"reqSec": { "reqSec": {
"median": 91848.73, "median": 29880,
"min": 91825.46, "min": 29744.73,
"max": 92599.28, "max": 29961.46,
"stddev": 296.55679952413783, "stddev": 90.38256681462417,
"cv": 0.00322222064035544 "cv": 0.003027383166346
}, },
"p50": 1, "p50": 3,
"p99": 1, "p99": 4,
"p999": 2 "p999": 6
} }
] ]
}, },
@@ -192,80 +192,80 @@
{ {
"framework": "raw-http", "framework": "raw-http",
"reqSec": { "reqSec": {
"median": 118996.37, "median": 39896.73,
"min": 118583.28, "min": 39847.28,
"max": 119584, "max": 40440.73,
"stddev": 341.82644850274596, "stddev": 235.6558649726337,
"cv": 0.002872466494470492 "cv": 0.0058846766178520865
}, },
"p50": 0, "p50": 2,
"p99": 1, "p99": 3,
"p999": 1 "p999": 5
}, },
{ {
"framework": "fastify", "framework": "fastify",
"reqSec": { "reqSec": {
"median": 86670.55, "median": 31436.37,
"min": 86490.19, "min": 31078.55,
"max": 86792.73, "max": 31562.91,
"stddev": 97.03476704769095, "stddev": 185.21052212010017,
"cv": 0.0011197471063834074 "cv": 0.005909263441314207
}, },
"p50": 1, "p50": 3,
"p99": 1, "p99": 4,
"p999": 2 "p999": 6
}, },
{ {
"framework": "express", "framework": "express",
"reqSec": { "reqSec": {
"median": 24325.1, "median": 10365.46,
"min": 24281.46, "min": 10170.55,
"max": 24406.55, "max": 10542.19,
"stddev": 50.44878456414985, "stddev": 129.83340146510884,
"cv": 0.002073096921615235 "cv": 0.01252603707960138
}, },
"p50": 3, "p50": 9,
"p99": 5, "p99": 12,
"p999": 8 "p999": 18
}, },
{ {
"framework": "green-tea", "framework": "green-tea",
"reqSec": { "reqSec": {
"median": 80078.55, "median": 26838.55,
"min": 80026.19, "min": 26783.28,
"max": 80375.28, "max": 26872,
"stddev": 126.5427427235537, "stddev": 35.930271582608675,
"cv": 0.00157915416330658 "cv": 0.0013390899572667937
}, },
"p50": 1, "p50": 3,
"p99": 2, "p99": 6,
"p999": 2 "p999": 8
}, },
{ {
"framework": "nestjs-express", "framework": "nestjs-express",
"reqSec": { "reqSec": {
"median": 20872, "median": 9256.37,
"min": 20800.73, "min": 9187.28,
"max": 20940.37, "max": 9302.19,
"stddev": 44.78034640330492, "stddev": 42.180541200890175,
"cv": 0.0021458031999967474 "cv": 0.0045584972844857205
}, },
"p50": 4, "p50": 10,
"p99": 6, "p99": 15,
"p999": 9 "p999": 22
}, },
{ {
"framework": "nestjs-fastify", "framework": "nestjs-fastify",
"reqSec": { "reqSec": {
"median": 89527.28, "median": 29402.91,
"min": 87572.37, "min": 29151.28,
"max": 90027.64, "max": 29689.46,
"stddev": 867.875358507201, "stddev": 189.99449229911926,
"cv": 0.009726340137622384 "cv": 0.006460862473261261
}, },
"p50": 1, "p50": 3,
"p99": 2, "p99": 4,
"p999": 2 "p999": 6
} }
] ]
}, },
@@ -276,80 +276,80 @@
{ {
"framework": "raw-http", "framework": "raw-http",
"reqSec": { "reqSec": {
"median": 104288, "median": 31783.28,
"min": 103776, "min": 31517.1,
"max": 104916.37, "max": 31824.73,
"stddev": 371.6125197245094, "stddev": 111.5598838292694,
"cv": 0.0035614220793380035 "cv": 0.003516116881358333
}, },
"p50": 0, "p50": 3,
"p99": 1, "p99": 5,
"p999": 1 "p999": 6
}, },
{ {
"framework": "fastify", "framework": "fastify",
"reqSec": { "reqSec": {
"median": 65905.46, "median": 20429.82,
"min": 65725.1, "min": 20397.82,
"max": 66366.55, "max": 20601.46,
"stddev": 217.1439762369652, "stddev": 73.12471046096515,
"cv": 0.0032914527300013986 "cv": 0.0035727493036941836
}, },
"p50": 1, "p50": 4,
"p99": 2, "p99": 8,
"p999": 3 "p999": 9
}, },
{ {
"framework": "express", "framework": "express",
"reqSec": { "reqSec": {
"median": 20297.46, "median": 8440.37,
"min": 20157.82, "min": 8407.64,
"max": 20413.82, "max": 8492,
"stddev": 99.50819415505447, "stddev": 29.52737333390846,
"cv": 0.004902635960088364 "cv": 0.003496408589959768
}, },
"p50": 4, "p50": 11,
"p99": 6, "p99": 16,
"p999": 10 "p999": 24
}, },
{ {
"framework": "green-tea", "framework": "green-tea",
"reqSec": { "reqSec": {
"median": 70298.19, "median": 22005.1,
"min": 68971.64, "min": 21736,
"max": 70606.55, "max": 22186.91,
"stddev": 704.8749988359651, "stddev": 149.1731413626461,
"cv": 0.01008804689681251 "cv": 0.006790967759795645
}, },
"p50": 1, "p50": 4,
"p99": 2, "p99": 7,
"p999": 3 "p999": 9
}, },
{ {
"framework": "nestjs-express", "framework": "nestjs-express",
"reqSec": { "reqSec": {
"median": 18787.64, "median": 7666.37,
"min": 18684.37, "min": 7645.28,
"max": 18861.82, "max": 7703.46,
"stddev": 57.13389375843402, "stddev": 20.418688106732038,
"cv": 0.0030419312672842124 "cv": 0.002662071942974812
}, },
"p50": 5, "p50": 12,
"p99": 7, "p99": 18,
"p999": 10 "p999": 26
}, },
{ {
"framework": "nestjs-fastify", "framework": "nestjs-fastify",
"reqSec": { "reqSec": {
"median": 63317.82, "median": 18596.8,
"min": 62453.82, "min": 18540.37,
"max": 63746.91, "max": 18658.19,
"stddev": 543.811870536126, "stddev": 37.943211988443956,
"cv": 0.00860786685722159 "cv": 0.0020404741150848267
}, },
"p50": 1, "p50": 4,
"p99": 2, "p99": 8,
"p999": 3 "p999": 11
} }
] ]
} }
@@ -358,89 +358,89 @@
{ {
"path": "/steps/0", "path": "/steps/0",
"steps": 0, "steps": 0,
"reqSec": 88107.64 "reqSec": 29196.37
}, },
{ {
"path": "/steps/3", "path": "/steps/3",
"steps": 3, "steps": 3,
"reqSec": 79950.55 "reqSec": 26563.64
}, },
{ {
"path": "/steps/5", "path": "/steps/5",
"steps": 5, "steps": 5,
"reqSec": 74126.55 "reqSec": 25314.19
} }
], ],
"secureCost": [ "secureCost": [
{ {
"label": "security:false (parity)", "label": "security:false (parity)",
"reqSec": 87473.46 "reqSec": 29776.73
}, },
{ {
"label": "security:true (default)", "label": "security:true (default)",
"reqSec": 83773.1 "reqSec": 28918.55
} }
], ],
"runtimes": [ "runtimes": [
{ {
"runtime": "node", "runtime": "node",
"scenario": "JSON hello (overhead)", "scenario": "JSON hello (overhead)",
"reqSec": 90976 "reqSec": 30378.91
}, },
{ {
"runtime": "node", "runtime": "node",
"scenario": "Route param", "scenario": "Route param",
"reqSec": 88904.73 "reqSec": 29203.64
}, },
{ {
"runtime": "node", "runtime": "node",
"scenario": "Pipeline (3 steps)", "scenario": "Pipeline (3 steps)",
"reqSec": 82045.1 "reqSec": 27208
}, },
{ {
"runtime": "node", "runtime": "node",
"scenario": "POST JSON + validation", "scenario": "POST JSON + validation",
"reqSec": 72235.64 "reqSec": 22608.73
}, },
{ {
"runtime": "deno", "runtime": "deno",
"scenario": "JSON hello (overhead)", "scenario": "JSON hello (overhead)",
"reqSec": 153408 "reqSec": 51888
}, },
{ {
"runtime": "deno", "runtime": "deno",
"scenario": "Route param", "scenario": "Route param",
"reqSec": 146368 "reqSec": 51785.6
}, },
{ {
"runtime": "deno", "runtime": "deno",
"scenario": "Pipeline (3 steps)", "scenario": "Pipeline (3 steps)",
"reqSec": 136256 "reqSec": 50692.37
}, },
{ {
"runtime": "deno", "runtime": "deno",
"scenario": "POST JSON + validation", "scenario": "POST JSON + validation",
"reqSec": 106661.82 "reqSec": 35742.55
}, },
{ {
"runtime": "bun", "runtime": "bun",
"scenario": "JSON hello (overhead)", "scenario": "JSON hello (overhead)",
"reqSec": 131674.19 "reqSec": 46299.64
}, },
{ {
"runtime": "bun", "runtime": "bun",
"scenario": "Route param", "scenario": "Route param",
"reqSec": 126909.1 "reqSec": 42788.37
}, },
{ {
"runtime": "bun", "runtime": "bun",
"scenario": "Pipeline (3 steps)", "scenario": "Pipeline (3 steps)",
"reqSec": 117489.46 "reqSec": 39643.64
}, },
{ {
"runtime": "bun", "runtime": "bun",
"scenario": "POST JSON + validation", "scenario": "POST JSON + validation",
"reqSec": 95124.37 "reqSec": 31960
} }
] ]
} }
+4 -1
View File
@@ -212,7 +212,10 @@ async function main(): Promise<void> {
const commit = execSync('git rev-parse --short HEAD').toString().trim(); const commit = execSync('git rev-parse --short HEAD').toString().trim();
const data: RenderData = { const data: RenderData = {
env: { env: {
date: new Date().toISOString().slice(0, 10), // Project time, not the runner's. A benchmark is often driven over ssh against a box that
// keeps UTC, and a run made on the evening of the 22nd then dates itself the 23rd — which
// reads as a day of drift against the commit and the changelog entry beside it.
date: new Date().toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }),
commit, commit,
node: process.version, node: process.version,
os: os.platform(), os: os.platform(),
+1 -1
View File
@@ -30,5 +30,5 @@ class Bench {
class BenchModule {} class BenchModule {}
const app = createApp({ modules: [BenchModule], security: false }); const app = createApp({ modules: [BenchModule], security: false });
const server = serveBun(app, { port: 0, hostname: '0.0.0.0' }); const server = await serveBun(app, { port: 0, hostname: '0.0.0.0' });
console.log(`READY ${server.port}`); console.log(`READY ${server.port}`);
+1 -1
View File
@@ -30,4 +30,4 @@ class Bench {
class BenchModule {} class BenchModule {}
const app = createApp({ modules: [BenchModule], security: false }); const app = createApp({ modules: [BenchModule], security: false });
serveDeno(app, { port: 0, hostname: '0.0.0.0', onListen: (a: { port: number }) => console.log(`READY ${a.port}`) }); await serveDeno(app, { port: 0, hostname: '0.0.0.0', onListen: (a: { port: number }) => console.log(`READY ${a.port}`) });
+10 -1
View File
@@ -1,5 +1,14 @@
{ {
"extends": "../tsconfig.json", "extends": "../tsconfig.json",
"compilerOptions": { "experimentalDecorators": true, "emitDecoratorMetadata": true, "noEmit": true }, "compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmit": true,
// The bench servers are ES modules, run by tsx, Deno and Bun rather than by the CommonJS build
// the root config describes. `serveDeno`/`serveBun` became async in 26.9.0-beta.2, so two of
// them now open with a top-level `await`, which `module: commonjs` rejects outright.
"module": "es2022",
"moduleResolution": "bundler"
},
"include": ["."] "include": ["."]
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@green-tea/core", "name": "@green-tea/core",
"version": "26.9.0-beta.1", "version": "26.9.0-beta.2",
"license": "MIT", "license": "MIT",
// JSR serves TypeScript source, not the tsup build, so these point at `src/` where npm's // JSR serves TypeScript source, not the tsup build, so these point at `src/` where npm's
// `exports` point at `dist/`. Same four entry points on purpose: a docs example that imports // `exports` point at `dist/`. Same four entry points on purpose: a docs example that imports
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "@green-tea/core", "name": "@green-tea/core",
"version": "26.8.0-beta.0", "version": "26.9.0-beta.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@green-tea/core", "name": "@green-tea/core",
"version": "26.8.0-beta.0", "version": "26.9.0-beta.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"reflect-metadata": "0.2.2" "reflect-metadata": "0.2.2"
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@green-tea/core", "name": "@green-tea/core",
"version": "26.9.0-beta.1", "version": "26.9.0-beta.2",
"description": "A zen, opinionated, type-safe framework \u2014 your API is a graph, not a middleware chain.", "description": "A zen, opinionated, type-safe framework \u2014 your API is a graph, not a middleware chain.",
"license": "MIT", "license": "MIT",
"author": "green-tea contributors <projects@expressive-tea.io>", "author": "green-tea contributors <projects@expressive-tea.io>",
+6 -5
View File
@@ -62,11 +62,12 @@ export interface App {
/** /**
* Boots the providers now, instead of on the first request. * Boots the providers now, instead of on the first request.
* *
* `listen()` already does this before it accepts a connection. Every other path — `app.fetch`, * The three serving helpers call it for you: `listen()` before it accepts a connection,
* `app.upgrade`, `serveDeno`, `serveBun`, `edgeHandler` — boots lazily on the first request, and a * `serveDeno()` and `serveBun()` before they bind. Calling it by hand is for the paths that have
* provider that throws there fails *every* request, answered by the runtime with a 500 that never * no startup of their own — `app.fetch` and `app.upgrade` driven by your own server, where a
* reaches `onError`. Calling this first turns that into a startup failure, which is where a bad * provider that throws fails *every* request, answered by the runtime with a 500 that never
* key or an unreachable database belongs. * reaches `onError`, because the boot memo keeps the rejection. 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 * Idempotent, and shares its memo with `listen()` and `fetch()`: calling both boots once. Unlike
* `ready()`, it does run provider factories. * `ready()`, it does run provider factories.
+13 -1
View File
@@ -74,8 +74,20 @@ function bunSocket(ws: BunServerWebSocket): WsSocket {
* (inbound channel, abort, WsRequest) is stashed on ws.data during the upgrade. * (inbound channel, abort, WsRequest) is stashed on ws.data during the upgrade.
* Bun.serve exposes no equivalent to Node's server.maxConnections; enforce connection caps at * Bun.serve exposes no equivalent to Node's server.maxConnections; enforce connection caps at
* the deployment platform or reverse proxy. * the deployment platform or reverse proxy.
*
* **Boots before it binds**, which is why it is async — see the `await app.boot()` below.
*/ */
export function serveBun(app: App, options?: BunServeShortOptions): BunServeResult { export async function serveBun(app: App, options?: BunServeShortOptions): Promise<BunServeResult> {
// The same gate `listen()` runs before it binds a socket, and for the same reason: resolve the
// graph and run the provider factories here, so a missing key or an unreachable pool is a startup
// failure rather than a 500 on every request.
//
// Leaving it to `app.fetch` is not the lazier equivalent. The boot memo keeps a *rejection*, so
// the first request would fix the failure in place and the runtime would answer from it forever,
// without ever reaching `onError`. This was documented as something the caller should remember to
// do, which made the correct use of a core helper depend on reading a README.
await app.boot();
const server = Bun.serve({ const server = Bun.serve({
...options, ...options,
fetch(request, server) { fetch(request, server) {
+13 -1
View File
@@ -51,8 +51,20 @@ declare const Deno: {
* WebSocket messages flow through app.upgrade over the shared neutral core. * WebSocket messages flow through app.upgrade over the shared neutral core.
* Deno.serve exposes no equivalent to Node's server.maxConnections; enforce connection caps at * Deno.serve exposes no equivalent to Node's server.maxConnections; enforce connection caps at
* the deployment platform or reverse proxy. * the deployment platform or reverse proxy.
*
* **Boots before it binds**, which is why it is async — see the `await app.boot()` below.
*/ */
export function serveDeno(app: App, options?: DenoServeOptions): DenoServer { export async function serveDeno(app: App, options?: DenoServeOptions): Promise<DenoServer> {
// The same gate `listen()` runs before it binds a socket, and for the same reason: resolve the
// graph and run the provider factories here, so a missing key or an unreachable pool is a startup
// failure rather than a 500 on every request.
//
// Leaving it to `app.fetch` is not the lazier equivalent. The boot memo keeps a *rejection*, so
// the first request would fix the failure in place and the runtime would answer from it forever,
// without ever reaching `onError`. This was documented as something the caller should remember to
// do, which made the correct use of a core helper depend on reading a README.
await app.boot();
// Deno's only force-close lever is the abort signal it was served with, so the adapter has to // Deno's only force-close lever is the abort signal it was served with, so the adapter has to
// own one to offer a deadline at all. A caller-supplied signal still works and still aborts the // own one to offer a deadline at all. A caller-supplied signal still works and still aborts the
// server — it is chained into ours rather than replaced, so neither party loses its control. // server — it is chained into ours rather than replaced, so neither party loses its control.
+10 -2
View File
@@ -5,8 +5,16 @@
*/ */
import 'reflect-metadata'; import 'reflect-metadata';
/** Package version, replaced at publish time. */ /**
export const VERSION = '26.8.0-beta.0'; * Package version. Kept in step with `package.json` and `deno.json` by hand, and pinned to them by
* `test/package-metadata.test.ts`.
*
* It used to say it was "replaced at publish time", which nothing ever did — not `tsup`, not
* `stage.yml`, not `release.yml`, which only ever *reads* the version out of `package.json`. So the
* constant drifted two releases behind while the comment explained why it could not, and the only
* test touching it checked the CalVer shape, which a stale version satisfies perfectly.
*/
export const VERSION = '26.9.0-beta.2';
// Application // Application
export { createApp } from './app'; export { createApp } from './app';
+4 -4
View File
@@ -48,9 +48,9 @@ function freePort(): number {
} }
/** Boot a teapot on a fixed port; the handle kills it and leaves the port free again. */ /** Boot a teapot on a fixed port; the handle kills it and leaves the port free again. */
function startTeapot(port: number) { async function startTeapot(port: number) {
const app = createApp({ modules: [TeapotModule], experimental: true, mesh: { secret: SECRET } }); const app = createApp({ modules: [TeapotModule], experimental: true, mesh: { secret: SECRET } });
const server = serveBun(app, { port }); const server = await serveBun(app, { port });
return { return {
stop: async () => { stop: async () => {
@@ -64,7 +64,7 @@ const settle = (ms: number) => new Promise((r) => setTimeout(r, ms));
test('mesh on Bun: a teacup reconnects to a teapot that came back', async () => { test('mesh on Bun: a teacup reconnects to a teapot that came back', async () => {
const port = freePort(); const port = freePort();
let teapot = startTeapot(port); let teapot = await startTeapot(port);
const teacup = createApp({ const teacup = createApp({
modules: [TeacupModule], modules: [TeacupModule],
@@ -88,7 +88,7 @@ test('mesh on Bun: a teacup reconnects to a teapot that came back', async () =>
const down = await teacup.fetch(new Request('http://x/api/local/who')); const down = await teacup.fetch(new Request('http://x/api/local/who'));
expect(down.status).toBe(503); expect(down.status).toBe(503);
teapot = startTeapot(port); teapot = await startTeapot(port);
await settle(400); await settle(400);
const after = await teacup.fetch(new Request('http://x/api/local/who', { headers: { 'x-token': 'xyz' } })); const after = await teacup.fetch(new Request('http://x/api/local/who', { headers: { 'x-token': 'xyz' } }));
+3 -3
View File
@@ -42,14 +42,14 @@ const controlUrl = (port: number) => `ws://127.0.0.1:${port}/__mesh__/control`;
test('mesh on Bun: teacup resolves a Bun teapot through the graph', async () => { test('mesh on Bun: teacup resolves a Bun teapot through the graph', async () => {
const teapot = createApp({ modules: [TeapotModule], experimental: true, mesh: { secret: SECRET } }); const teapot = createApp({ modules: [TeapotModule], experimental: true, mesh: { secret: SECRET } });
const tServer = serveBun(teapot, { port: 0 }); const tServer = await serveBun(teapot, { port: 0 });
const teacup = createApp({ const teacup = createApp({
modules: [TeacupModule], modules: [TeacupModule],
experimental: true, experimental: true,
mesh: { teapots: [{ url: controlUrl(tServer.port), secret: SECRET }] }, mesh: { teapots: [{ url: controlUrl(tServer.port), secret: SECRET }] },
}); });
const cServer = serveBun(teacup, { port: 0 }); const cServer = await serveBun(teacup, { port: 0 });
try { try {
const res = await fetch(`http://127.0.0.1:${cServer.port}/api/local/who`, { headers: { 'x-token': 'abc' } }); const res = await fetch(`http://127.0.0.1:${cServer.port}/api/local/who`, { headers: { 'x-token': 'abc' } });
@@ -67,7 +67,7 @@ test('mesh on Bun: teacup resolves a Bun teapot through the graph', async () =>
test('mesh on Bun: a teapot refuses a bad secret over its control channel', async () => { test('mesh on Bun: a teapot refuses a bad secret over its control channel', async () => {
const teapot = createApp({ modules: [TeapotModule], experimental: true, mesh: { secret: SECRET } }); const teapot = createApp({ modules: [TeapotModule], experimental: true, mesh: { secret: SECRET } });
const tServer = serveBun(teapot, { port: 0 }); const tServer = await serveBun(teapot, { port: 0 });
const teacup = createApp({ const teacup = createApp({
modules: [TeacupModule], modules: [TeacupModule],
+29 -4
View File
@@ -6,7 +6,7 @@
// Run with: npm run test:bun (or: bun test test/bun/) // Run with: npm run test:bun (or: bun test test/bun/)
import 'reflect-metadata'; import 'reflect-metadata';
import { test, expect } from 'bun:test'; import { test, expect } from 'bun:test';
import { createApp, Route, Get, Module } from '../../src/index.ts'; import { createApp, Route, Get, Module, Provider, needs } from '../../src/index.ts';
import { serveBun } from '../../src/bun.ts'; import { serveBun } from '../../src/bun.ts';
@Route('/') @Route('/')
@@ -25,7 +25,7 @@ class Ctl {
class M {} class M {}
test('serveBun close({ timeoutMs }) gives up on a stuck handler and resolves', async () => { test('serveBun close({ timeoutMs }) gives up on a stuck handler and resolves', async () => {
const server = serveBun(createApp({ modules: [M] }), { port: 0 }); const server = await serveBun(createApp({ modules: [M] }), { port: 0 });
fetch(`http://127.0.0.1:${server.port}/hang`).catch(() => {}); fetch(`http://127.0.0.1:${server.port}/hang`).catch(() => {});
await Bun.sleep(50); // let the request actually reach the handler await Bun.sleep(50); // let the request actually reach the handler
@@ -40,7 +40,7 @@ test('serveBun close({ timeoutMs }) gives up on a stuck handler and resolves', a
}); });
test('serveBun close() drains an in-flight request rather than cutting it', async () => { test('serveBun close() drains an in-flight request rather than cutting it', async () => {
const server = serveBun(createApp({ modules: [M] }), { port: 0 }); const server = await serveBun(createApp({ modules: [M] }), { port: 0 });
const inFlight = fetch(`http://127.0.0.1:${server.port}/slow`).then((r) => r.json()); const inFlight = fetch(`http://127.0.0.1:${server.port}/slow`).then((r) => r.json());
await Bun.sleep(50); // the request must be *in* the handler before we close, or it never got in await Bun.sleep(50); // the request must be *in* the handler before we close, or it never got in
@@ -65,10 +65,35 @@ test('serveBun close() runs registered teardown', async () => {
}), }),
}], }],
}); });
const server = serveBun(app, { port: 0 }); const server = await serveBun(app, { port: 0 });
await server.close({ timeoutMs: 2000 }); await server.close({ timeoutMs: 2000 });
// Reverse registration order: the plugin registered after the hook, so it tears down first. // Reverse registration order: the plugin registered after the hook, so it tears down first.
expect(closed).toEqual(['plugin', 'hook']); expect(closed).toEqual(['plugin', 'hook']);
}); });
// The boot gate, which is why serveBun is async. Before it, a provider that threw was memoized as a
// rejection and answered 500 to every request from the runtime, never reaching onError — so the
// failure looked like a runtime fault at 3am instead of a deploy that refused to start.
@Provider({ provides: 'key' })
class BadKey {
provide(): never {
throw new Error('no such key file');
}
}
@Route('/')
class NeedsKey {
@Get('/signed')
signed(@needs('key') key: string) {
return { key };
}
}
@Module({ mountpoint: '/', providers: [BadKey], controllers: [NeedsKey] })
class KeyModule {}
test('serveBun rejects when a provider fails, instead of binding a port that 500s', async () => {
const app = createApp({ modules: [KeyModule] });
await expect(serveBun(app, { port: 0 })).rejects.toThrow(/no such key file/);
});
+1 -1
View File
@@ -26,7 +26,7 @@ class M {}
test('serveBun: HTTP + WebSocket round-trip', async () => { test('serveBun: HTTP + WebSocket round-trip', async () => {
const app = createApp({ modules: [M] }); const app = createApp({ modules: [M] });
const server = serveBun(app, { port: 0 }); const server = await serveBun(app, { port: 0 });
const port = server.port; const port = server.port;
try { try {
const httpRes = await fetch(`http://127.0.0.1:${port}/rt/hello`); const httpRes = await fetch(`http://127.0.0.1:${port}/rt/hello`);
+4 -1
View File
@@ -32,7 +32,10 @@ it('snapshots connection metadata before Deno invalidates the upgraded request',
// `handleSignals` is a pass-through here: this test is about upgrade metadata, and the identity // `handleSignals` is a pass-through here: this test is about upgrade metadata, and the identity
// it returns is exactly what `createApp` returns when `handleSignals` is left off. // it returns is exactly what `createApp` returns when `handleSignals` is left off.
const handleSignals = <T,>(closer: T): T => closer; const handleSignals = <T,>(closer: T): T => closer;
serveDeno({ upgrade, handleSignals } as unknown as App); // `serveDeno` boots before it binds, so the stub needs the gate even though this test never
// exercises it.
const boot = vi.fn().mockResolvedValue(undefined);
await serveDeno({ upgrade, handleSignals, boot } as unknown as App);
const info = { const info = {
get remoteAddr() { get remoteAddr() {
if (upgraded) throw new TypeError('Request closed'); if (upgraded) throw new TypeError('Request closed');
+1 -1
View File
@@ -22,7 +22,7 @@ class TeapotModule {}
async function startTeapot() { async function startTeapot() {
const app = createApp({ modules: [TeapotModule], experimental: true, mesh: { secret: 'good' } }); const app = createApp({ modules: [TeapotModule], experimental: true, mesh: { secret: 'good' } });
let port = 0; let port = 0;
const server = serveDeno(app, { port: 0, onListen: (addr) => (port = addr.port) }); const server = await serveDeno(app, { port: 0, onListen: (addr) => (port = addr.port) });
await new Promise((r) => setTimeout(r, 50)); await new Promise((r) => setTimeout(r, 50));
return { port: () => port, stop: async () => { await server.shutdown(); await app.close(); } }; return { port: () => port, stop: async () => { await server.shutdown(); await app.close(); } };
+1 -1
View File
@@ -127,7 +127,7 @@ Deno.test('interop: a Node teacup consumes a Deno teapot', async () => {
const teapot = createApp({ modules: [TeapotModule], experimental: true, mesh: { secret: SECRET } }); const teapot = createApp({ modules: [TeapotModule], experimental: true, mesh: { secret: SECRET } });
let port = 0; let port = 0;
const { serveDeno } = await import('../../src/deno.ts'); const { serveDeno } = await import('../../src/deno.ts');
const server = serveDeno(teapot, { const server = await serveDeno(teapot, {
port: 0, port: 0,
onListen: (addr) => { onListen: (addr) => {
port = addr.port; port = addr.port;
+1 -1
View File
@@ -49,7 +49,7 @@ function freePort(): number {
/** Boot a teapot on a fixed port; the returned handle can kill it and leave the port free again. */ /** Boot a teapot on a fixed port; the returned handle can kill it and leave the port free again. */
async function startTeapot(port: number) { async function startTeapot(port: number) {
const app = createApp({ modules: [TeapotModule], experimental: true, mesh: { secret: SECRET } }); const app = createApp({ modules: [TeapotModule], experimental: true, mesh: { secret: SECRET } });
const server = serveDeno(app, { port }); const server = await serveDeno(app, { port });
await new Promise((r) => setTimeout(r, 50)); await new Promise((r) => setTimeout(r, 50));
return { return {
+1 -1
View File
@@ -46,7 +46,7 @@ class TeacupModule {}
/** Starts an app on Deno and resolves once its port is known. */ /** Starts an app on Deno and resolves once its port is known. */
async function serve(app: ReturnType<typeof createApp>) { async function serve(app: ReturnType<typeof createApp>) {
let port = 0; let port = 0;
const server = serveDeno(app, { const server = await serveDeno(app, {
port: 0, port: 0,
onListen: (addr) => { onListen: (addr) => {
port = addr.port; port = addr.port;
+39 -5
View File
@@ -5,7 +5,7 @@
// //
// Run with: npm run test:deno // Run with: npm run test:deno
import 'reflect-metadata'; import 'reflect-metadata';
import { createApp, Route, Get, Module } from '../../src/index.ts'; import { createApp, Route, Get, Module, Provider, needs } from '../../src/index.ts';
import { serveDeno } from '../../src/deno.ts'; import { serveDeno } from '../../src/deno.ts';
@Route('/') @Route('/')
@@ -30,7 +30,7 @@ const portOf = (server: { addr?: { port: number } }): number => server.addr!.por
// the uncaught BadResource that aborting a draining server produces. The test runner fails on // the uncaught BadResource that aborting a draining server produces. The test runner fails on
// that error even when the assertions pass, so a green run here is the real assertion. // that error even when the assertions pass, so a green run here is the real assertion.
Deno.test('serveDeno close({ timeoutMs }) returns on a stuck handler without forcing', async () => { Deno.test('serveDeno close({ timeoutMs }) returns on a stuck handler without forcing', async () => {
const server = serveDeno(createApp({ modules: [M] }), { port: 0, onListen: () => {} }); const server = await serveDeno(createApp({ modules: [M] }), { port: 0, onListen: () => {} });
fetch(`http://127.0.0.1:${portOf(server)}/hang`).catch(() => {}); fetch(`http://127.0.0.1:${portOf(server)}/hang`).catch(() => {});
await new Promise((r) => setTimeout(r, 50)); // let the request actually reach the handler await new Promise((r) => setTimeout(r, 50)); // let the request actually reach the handler
@@ -45,7 +45,7 @@ Deno.test('serveDeno close({ timeoutMs }) returns on a stuck handler without for
}); });
Deno.test('serveDeno close() drains an in-flight request rather than cutting it', async () => { Deno.test('serveDeno close() drains an in-flight request rather than cutting it', async () => {
const server = serveDeno(createApp({ modules: [M] }), { port: 0, onListen: () => {} }); const server = await serveDeno(createApp({ modules: [M] }), { port: 0, onListen: () => {} });
const inFlight = fetch(`http://127.0.0.1:${portOf(server)}/slow`).then((r) => r.json()); const inFlight = fetch(`http://127.0.0.1:${portOf(server)}/slow`).then((r) => r.json());
await new Promise((r) => setTimeout(r, 50)); // must be *in* the handler before we close await new Promise((r) => setTimeout(r, 50)); // must be *in* the handler before we close
@@ -58,7 +58,7 @@ Deno.test('serveDeno close() drains an in-flight request rather than cutting it'
Deno.test('a caller-supplied signal still aborts the server', async () => { Deno.test('a caller-supplied signal still aborts the server', async () => {
const ac = new AbortController(); const ac = new AbortController();
const server = serveDeno(createApp({ modules: [M] }), { port: 0, signal: ac.signal, onListen: () => {} }); const server = await serveDeno(createApp({ modules: [M] }), { port: 0, signal: ac.signal, onListen: () => {} });
ac.abort(); ac.abort();
await server.finished; // hangs here if chaining the caller's signal into ours dropped it await server.finished; // hangs here if chaining the caller's signal into ours dropped it
@@ -80,10 +80,44 @@ Deno.test('serveDeno close() runs registered teardown', async () => {
}), }),
}], }],
}); });
const server = serveDeno(app, { port: 0 }); const server = await serveDeno(app, { port: 0 });
await server.close({ timeoutMs: 2000 }); await server.close({ timeoutMs: 2000 });
// Reverse registration order: the plugin registered after the hook, so it tears down first. // Reverse registration order: the plugin registered after the hook, so it tears down first.
if (closed.join(',') !== 'plugin,hook') throw new Error(`expected plugin,hook — got ${closed.join(',')}`); if (closed.join(',') !== 'plugin,hook') throw new Error(`expected plugin,hook — got ${closed.join(',')}`);
}); });
// The boot gate, which is why serveDeno is async. Before it, a provider that threw was memoized as
// a rejection and answered 500 to every request from the runtime, never reaching onError — so the
// failure looked like a runtime fault at 3am instead of a deploy that refused to start.
@Provider({ provides: 'key' })
class BadKey {
provide(): never {
throw new Error('no such key file');
}
}
@Route('/')
class NeedsKey {
@Get('/signed')
signed(@needs('key') key: string) {
return { key };
}
}
@Module({ mountpoint: '/', providers: [BadKey], controllers: [NeedsKey] })
class KeyModule {}
Deno.test('serveDeno rejects when a provider fails, instead of binding a port that 500s', async () => {
const app = createApp({ modules: [KeyModule] });
let message = '';
try {
await serveDeno(app, { port: 0, onListen: () => {} });
} catch (error) {
message = (error as Error).message;
}
if (!message.includes('no such key file')) {
throw new Error(`expected serveDeno to reject with the provider's error, got: ${message || '<resolved>'}`);
}
});
+1 -1
View File
@@ -37,7 +37,7 @@ Deno.test('serveDeno: HTTP + WebSocket round-trip through the graph', async () =
const app = createApp({ modules: [M] }); const app = createApp({ modules: [M] });
let port = 0; let port = 0;
const server = serveDeno(app, { const server = await serveDeno(app, {
port: 0, port: 0,
onListen: (addr) => { onListen: (addr) => {
port = addr.port; port = addr.port;
+1 -1
View File
@@ -23,7 +23,7 @@ const app = createApp({
// `ready` is printed after `serveDeno` returns, not from `onListen` — Deno calls `onListen` // `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 // 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. // 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 })); console.log(JSON.stringify({ ready: true }));
void server; void server;
+16
View File
@@ -3,6 +3,8 @@ import { resolve } from 'node:path';
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { VERSION } from '../src/index';
interface PackageMetadata { interface PackageMetadata {
readonly repository?: { readonly repository?: {
readonly type?: string; readonly type?: string;
@@ -75,3 +77,17 @@ describe('JSR manifest agrees with package.json', () => {
expect(Object.keys(denoJson.exports ?? {})).toEqual(npmEntries); expect(Object.keys(denoJson.exports ?? {})).toEqual(npmEntries);
}); });
}); });
// The third place the version is written, and the one nothing was watching. `VERSION` is what a
// consumer reads at runtime — a bug report, a health endpoint, a support thread all quote it — so a
// stale one sends someone to the changelog of a release they are not running.
//
// It carried a comment promising it was "replaced at publish time", and no such step existed: not in
// `tsup.config.ts`, not in `stage.yml`, not in `release.yml`, which only reads the version out of
// `package.json`. Two releases of drift went unnoticed because `smoke.test.ts` asserts the CalVer
// *shape*, which any stale version still matches. Shape was never the question.
describe('the exported VERSION agrees with package.json', () => {
it('is the version this package publishes under', () => {
expect(VERSION).toBe(packageJson.version);
});
});