the cors.origins predicate ran two or three times per request
#72 and #69 are the published artifact being broken — one exits the process on any cross-origin request, the other kills @Html at boot on Deno and misdiagnoses two more call sites as runtime limitations. #70 was a claim in the README that was not true. #66 was an oversight in the barrel. #77 was found by fixing #72 and was pulled into the tier deliberately, because it lives in the files #72 already touched and ships in the same beta.
The predicate runs on the request path, above the region where errors convert to a response, so a throw became a rejected promise nobody awaited and Node exited. The guard goes at originAllowed, the single point all four call sites funnel through. A predicate that throws denies the origin: a lookup that failed has not said yes, and a broken allowlist must never widen into an open one. Reported through the app logger.
Converting it to a 500 was the alternative, rejected because two of the four call sites run before any error boundary exists — it would have meant restructuring three of them to gain a worse default.
Verified against the built dist/ with the issue's own reproduction: all four paths that exited code 1 now answer, process alive.
Amends one test from the maxConcurrentRequests contribution which asserted the old crash as its baseline while proving the gate does not leak a slot. It still proves that.
JSR publishes src/ and runs no bundler, so tsup's banner never existed there. @Html('file') died at boot on Deno with ReferenceError: require is not defined; the two guarded sites were worse than the crash, answering confidently and wrongly — static blamed "edge, no filesystem" while running on Deno, multipart reported busboy missing while it sat in node_modules.
All ten call sites now go through one nodeRequire: the ambient require first, so the CJS build and the banner-carrying ESM build behave exactly as before, and otherwise one rebuilt from process.getBuiltinModule('node:module') — which Node 22.3+, Deno and Bun all expose synchronously, the actual requirement since every caller sits on a sync path. It resolves from process.cwd(), because a peer dependency belongs to the application, not to a module served over https from a registry. On workerd, where esbuild rewrites the call into its own throwing stub, nothing changes and the guarded sites' "edge has no filesystem" story is finally the true one.
The Deno suite already imported src/ exactly as JSR serves it — no test had touched a path that lazily loads a Node builtin, which is how a package that died at boot kept a green suite. It does now, both branches of the shim.
Off by default, and that is the design: a library that installs process-wide handlers behind your back is worse than one that installs none. Both halves are supported and documented now — keep the handler, or hand it over. What is not optional either way is that something calls close(), and the README says so instead of implying the framework had it covered.
Declared once on createApp, wired per runtime by whichever boot call runs: listen(), serveDeno() and serveBun() each pass the closer that drains their server. The returned close unregisters, which on Deno is load-bearing rather than tidy — a live Deno.addSignalListener holds the process open.
Unregistering first also means a second signal falls through to the platform default and ends the process at once. Deliberate: Ctrl-C twice is the way out of a stuck teardown, and swallowing it for a 10s budget would read as a hang. An orchestrator sends SIGTERM once and then SIGKILL, so it never gets there.
Tested against real processes, because a handler whose job is to exit its own process cannot be fired by hand in the runner. Node covers SIGTERM, SIGINT, the double-signal escape hatch and the default-off case; Deno covers Deno.addSignalListener/Deno.exit, the API that actually differs. Bun shares Node's process path and has no signal test of its own — its wiring is the same line as Deno's, which is covered.
TransformerFn, plus four more found by checking the barrel for the same shape: PluginApi, ScopeApi and ScopeNode (the chain reached through api.scope.add, so a plugin split into named functions cannot annotate what it receives), Hooks, and TeardownFn. Types only — nothing at runtime moves. A type test now fails to compile if any of them, or the two that were already exported, leaves the barrel again.
security and cors were computed twice per request and three times for a preflight: once in the adapter, to seed the headers a response written abovehandle() still has to carry, and again in dispatch, plus a third time inside corsPreflightHeaders.
Nothing was incorrect — the predicate is expected to be pure with respect to one request. The cost is that cors.origins is a predicate precisely so it can be a lookup, and the framework charged the caller's latency budget and their backend two to three times for an answer whose inputs did not change in between.
handle() now takes the headers the adapter already computed, with computeInjected kept as the fallback for a caller that has none, and corsPreflightHeaders extends that result. The Node adapter was carrying its own inlined copy of computeInjected; it uses the real one now, which removes the duplicate rather than papering over it.
Measured against the built dist/, same script that produced the numbers in the issue:
GET with Origin 2x -> 1x
OPTIONS preflight 3x -> 1x
buildFetch, Origin 2x -> 1x
GET without Origin 0x -> 0x (never reached the predicate; unchanged)
The risk here is not the call count, it is that injected carries the security headers onto every response shape — so the tests that matter are the existing ones across transport-security, http-headers, fetch, parity and web-stream. The two new tests assert the count directly on both adapters.
One CI failure worth recording
build went red on the first push of #70 while everything was green locally. The subprocess tests spawned npx tsx: macOS npx execs into node so the signal reached the app, Linux leaves node a grandchild so SIGTERM landed on the wrapper and the app never heard it. Fixed by spawning process.execPath -r tsx/cjs directly — no wrapper. -r rather than --import/--loader because it is the one form that works on both the Node 18 floor CI builds against and the current release; verified by installing Node 18 and running all three variants, then running the whole suite under it. Node 18 is now part of the local gate run for this branch.
Gates on b8b3548
lint 0 errors (48 pre-existing warnings)
complexity:check every function <= 25
typecheck clean
format:check clean
build clean
npm test 466 passed / 69 files (457 / 67 at branch point)
npm test (node 18) 465 passed (CI's build floor)
test:deno 17 passed (12 at branch point)
test:bun 7 passed
test:edge PASS
deno publish dry run clean, node-require.ts included
Not touched, by decision: the version bump to 26.9.0-beta.1 and the CHANGELOG both land when the beta is cut, not per PR.
One branch for the whole tier, one commit per issue. All five are in.
Replaces #76, which carried the first commit on a per-issue branch before we settled on a branch per tier.
| Issue | Commit | What it was |
|---|---|---|
| #72 | `bb0b01c` | a `cors.origins` predicate that throws took the process down |
| #69 | `4896ee8` | the JSR package shipped source assuming tsup's `createRequire` banner |
| #70 | `e5d5fb8` | "not a SIGTERM handler you write", except nothing called `close()` |
| #66 | `855e044` | `TransformerFn` was not exported, so a custom `@Transformer` could not be typed |
| #77 | `b8b3548` | the `cors.origins` predicate ran two or three times per request |
#72 and #69 are the published artifact being broken — one exits the process on any cross-origin request, the other kills `@Html` at boot on Deno and misdiagnoses two more call sites as runtime limitations. #70 was a claim in the README that was not true. #66 was an oversight in the barrel. #77 was found by fixing #72 and was pulled into the tier deliberately, because it lives in the files #72 already touched and ships in the same beta.
## #72 — deny the origin when the predicate throws
The predicate runs on the request path, above the region where errors convert to a response, so a throw became a rejected promise nobody awaited and Node exited. The guard goes at `originAllowed`, the single point all four call sites funnel through. A predicate that throws **denies** the origin: a lookup that failed has not said yes, and a broken allowlist must never widen into an open one. Reported through the app logger.
Converting it to a 500 was the alternative, rejected because two of the four call sites run before any error boundary exists — it would have meant restructuring three of them to gain a worse default.
Verified against the built `dist/` with the issue's own reproduction: all four paths that exited code 1 now answer, process alive.
Amends one test from the `maxConcurrentRequests` contribution which asserted the old crash as its baseline while proving the gate does not leak a slot. It still proves that.
## #69 — resolve `require` from source
JSR publishes `src/` and runs no bundler, so tsup's banner never existed there. `@Html('file')` died at boot on Deno with `ReferenceError: require is not defined`; the two guarded sites were worse than the crash, answering confidently and wrongly — `static` blamed "edge, no filesystem" while running on Deno, multipart reported busboy missing while it sat in `node_modules`.
All ten call sites now go through one `nodeRequire`: the ambient `require` first, so the CJS build and the banner-carrying ESM build behave **exactly** as before, and otherwise one rebuilt from `process.getBuiltinModule('node:module')` — which Node 22.3+, Deno and Bun all expose *synchronously*, the actual requirement since every caller sits on a sync path. It resolves from `process.cwd()`, because a peer dependency belongs to the application, not to a module served over https from a registry. On workerd, where esbuild rewrites the call into its own throwing stub, nothing changes and the guarded sites' "edge has no filesystem" story is finally the true one.
The Deno suite already imported `src/` exactly as JSR serves it — no test had touched a path that lazily loads a Node builtin, which is how a package that died at boot kept a green suite. It does now, both branches of the shim.
## #70 — `createApp({ handleSignals: true })`
Off by default, and that is the design: a library that installs process-wide handlers behind your back is worse than one that installs none. Both halves are supported and documented now — keep the handler, or hand it over. What is not optional either way is that *something* calls `close()`, and the README says so instead of implying the framework had it covered.
Declared once on `createApp`, wired per runtime by whichever boot call runs: `listen()`, `serveDeno()` and `serveBun()` each pass the closer that drains *their* server. The returned close unregisters, which on Deno is load-bearing rather than tidy — a live `Deno.addSignalListener` holds the process open.
Unregistering first also means a **second** signal falls through to the platform default and ends the process at once. Deliberate: Ctrl-C twice is the way out of a stuck teardown, and swallowing it for a 10s budget would read as a hang. An orchestrator sends SIGTERM once and then SIGKILL, so it never gets there.
Tested against real processes, because a handler whose job is to exit its own process cannot be fired by hand in the runner. Node covers SIGTERM, SIGINT, the double-signal escape hatch and the default-off case; Deno covers `Deno.addSignalListener`/`Deno.exit`, the API that actually differs. **Bun shares Node's `process` path and has no signal test of its own** — its wiring is the same line as Deno's, which is covered.
## #66 — export the extension-point types
`TransformerFn`, plus four more found by checking the barrel for the same shape: `PluginApi`, `ScopeApi` and `ScopeNode` (the chain reached through `api.scope.add`, so a plugin split into named functions cannot annotate what it receives), `Hooks`, and `TeardownFn`. Types only — nothing at runtime moves. A type test now fails to compile if any of them, or the two that were already exported, leaves the barrel again.
## #77 — resolve the request's headers once
`security` and `cors` were computed twice per request and three times for a preflight: once in the adapter, to seed the headers a response written *above* `handle()` still has to carry, and again in `dispatch`, plus a third time inside `corsPreflightHeaders`.
Nothing was incorrect — the predicate is expected to be pure with respect to one request. The cost is that `cors.origins` is a predicate precisely so it can be a lookup, and the framework charged the caller's latency budget and their backend two to three times for an answer whose inputs did not change in between.
`handle()` now takes the headers the adapter already computed, with `computeInjected` kept as the fallback for a caller that has none, and `corsPreflightHeaders` extends that result. The Node adapter was carrying its own inlined copy of `computeInjected`; it uses the real one now, which removes the duplicate rather than papering over it.
Measured against the built `dist/`, same script that produced the numbers in the issue:
GET with Origin 2x -> 1x
OPTIONS preflight 3x -> 1x
buildFetch, Origin 2x -> 1x
GET without Origin 0x -> 0x (never reached the predicate; unchanged)
The risk here is not the call count, it is that `injected` carries the security headers onto every response shape — so the tests that matter are the existing ones across `transport-security`, `http-headers`, `fetch`, `parity` and `web-stream`. The two new tests assert the count directly on both adapters.
## One CI failure worth recording
`build` went red on the first push of #70 while everything was green locally. The subprocess tests spawned `npx tsx`: macOS `npx` execs into node so the signal reached the app, Linux leaves node a *grandchild* so SIGTERM landed on the wrapper and the app never heard it. Fixed by spawning `process.execPath -r tsx/cjs` directly — no wrapper. `-r` rather than `--import`/`--loader` because it is the one form that works on both the Node 18 floor CI builds against and the current release; verified by installing Node 18 and running all three variants, then running the whole suite under it. Node 18 is now part of the local gate run for this branch.
## Gates on `b8b3548`
lint 0 errors (48 pre-existing warnings)
complexity:check every function <= 25
typecheck clean
format:check clean
build clean
npm test 466 passed / 69 files (457 / 67 at branch point)
npm test (node 18) 465 passed (CI's build floor)
test:deno 17 passed (12 at branch point)
test:bun 7 passed
test:edge PASS
deno publish dry run clean, node-require.ts included
Not touched, by decision: the version bump to `26.9.0-beta.1` and the CHANGELOG both land when the beta is cut, not per PR.
`CorsOptions.origins` accepts a predicate, and it runs on the request path above the
region where errors convert to a response. A predicate that threw became a rejected
promise nobody awaited, and Node's default for that is to exit — so one cross-origin
GET took the process down, with `onError` never reaching it.
The trigger is a browser: `originAllowed` only runs when an `Origin` header is present,
so the crash is reachable by any cross-origin client and by no test that forgets the
header, which is how it survived a green suite.
Guard the call at `originAllowed`, the single point all four call sites funnel through
(the Node handler, `computeInjected` on both adapters, and the preflight path). A
predicate that throws denies the origin: a lookup that failed has not said yes, and a
broken allowlist must never widen into an open one. The failure is reported through the
app logger rather than swallowed — `HttpOptions` already carries one.
The published behaviour changes for a throwing predicate only. Every other origin shape
is untouched, and the security headers still land on the response.
Amends one test from the `maxConcurrentRequests` contribution, which asserted the old
crash as its baseline while proving the gate does not leak a slot. It still proves that,
against a transient failure that is now answered rather than fatal.
Closes#72.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
JSR publishes `src/` and runs no bundler, so the `createRequire` banner tsup gives
the ESM build (tsup.config.ts) never exists there. Every lazy `require(...)` in the
source had nothing to resolve, and one of them was unguarded: `@Html('file')` and
template mode died at boot on Deno with `ReferenceError: require is not defined`.
The two guarded sites were worse than the crash, because they answered confidently
and wrongly. `static` reported *"needs a filesystem and is unavailable on this
runtime (edge)"* while running on Deno, which has one; multipart reported busboy as
not installed while it sat in node_modules. Both blamed the runtime for a packaging
problem, and both named a runtime the reader was not on.
Route all ten call sites through one `nodeRequire`, which prefers the ambient
`require` — so the CJS build and the banner-carrying ESM build behave exactly as
before — and otherwise rebuilds one from `process.getBuiltinModule('node:module')`.
Node 22.3+, Deno and Bun all expose that synchronously, which is the requirement:
every caller sits on a sync path a dynamic `import()` could not serve. It resolves
from `process.cwd()`, since a peer dependency like busboy belongs to the application,
not to a module served over https from a registry.
Where neither exists — workerd, where esbuild rewrites the call into its own throwing
stub — the behaviour is unchanged: the guarded sites still catch, and their "edge has
no filesystem" story is finally the true one.
Covered by a Deno suite that imports `src/` exactly as JSR serves it. The other Deno
tests already did that; none of them touched a path that loads a Node builtin lazily,
which is how a package that died at boot kept a green suite.
Closes#69.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The README promised shutdown was *"an extension point, not a SIGTERM handler you
write"*. Half of it was true: `dispose()`, `onShutdown` and `hooks` all deliver the
*content* of teardown, but nothing called `close()`, so every application still wrote
the handler — and wrote it three times, because the spelling is per runtime. Forget it
and the container is SIGKILLed after its grace period, every `dispose()` the registry
so carefully ordered never runs, and nothing reports it.
`createApp({ handleSignals: true })` registers SIGINT/SIGTERM to close and exit.
Off by default, and that is the design rather than caution: a library that installs
process-wide handlers behind your back is worse than one that installs none, because
when the process exits is the application's call. Both halves are now supported and
documented — keep the handler, or hand it over. What is not optional either way is
that *something* calls `close()`, and the README now says so instead of implying the
framework already had it covered.
Declared once on `createApp`, wired per runtime by whichever boot call runs:
`listen()`, `serveDeno()` and `serveBun()` each pass the closer that drains *their*
server to `app.handleSignals`, which returns a close that also unregisters. On Deno
that unregistering is load-bearing rather than tidy — a live `Deno.addSignalListener`
holds the process open, so an app that closed itself would otherwise hang.
Unregistering first also means a *second* signal falls through to the platform default
and ends the process at once. That is deliberate: Ctrl-C twice is the way out of a
teardown that is stuck, and swallowing it for the length of a 10s budget would read as
a hang. An orchestrator sends SIGTERM once and then SIGKILL, so it never gets there.
Tested against real processes, because a handler whose job is to exit its own process
cannot be fired by hand in the runner: Node covers SIGTERM, SIGINT, the double-signal
escape hatch and the default-off case; Deno covers `Deno.addSignalListener`/`Deno.exit`,
which is the API that actually differs. Bun shares Node's `process` path.
Closes#70.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
`Transformer` was exported and `TransformerFn` was not, so a custom transformer could
be attached but not typed. The workaround is to borrow the type off a value —
`const text: typeof JsonTransformer = ...` — which works and reads like a trick,
because it is one. `ErrorRenderer` and `StreamEncoder`, the two neighbouring extension
points, were both already exported; this one was an oversight rather than a decision.
Checking the rest of the barrel for the same shape turned up four more. A plugin split
into named functions rather than one inline arrow cannot annotate what it receives:
`Plugin` types the arrow, and `PluginApi`, `ScopeApi` and `ScopeNode` — the chain
reached through `api.scope.add`, which is how a plugin contributes to the graph — were
all unreachable. So was `Hooks`, which makes `createApp({ hooks })` typeable only
inline, and `TeardownFn`, the shape every one of those three doors takes.
Types only. Nothing at runtime moves, and no existing export changes.
Covered by a type test that fails to compile if any of them leaves the barrel again,
including the two that were already there — the failure mode this fixes is a barrel
edit nobody notices until a user writes the annotation.
Closes#66.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
`security` and `cors` were computed twice for every request and three times for a
preflight: once in the adapter, to seed the headers a response written *above*
`handle()` still has to carry — a shed 503, a 413 from the body reader — and again in
`dispatch`, plus a third time inside `corsPreflightHeaders`.
Nothing was incorrect, because the predicate is expected to be pure with respect to one
request. The cost is that `cors.origins` is a predicate precisely so it can be a lookup:
an allowlist in Redis, a tenant query. The framework charged the caller's latency budget
and their backend two to three times for an answer whose inputs did not change in
between, and made a predicate with a counter in it count double.
`handle()` now takes the headers the adapter already computed and hands them down, with
`computeInjected` kept as the fallback for a caller that has none.
`corsPreflightHeaders` extends that result instead of re-deriving it. The Node adapter
was carrying its own copy of `computeInjected`, inlined; it uses the real one now, which
is what removes the duplicate rather than papering over it.
Measured against the built `dist/`, same script that produced the numbers in the issue:
GET with Origin 2x -> 1x
OPTIONS preflight 3x -> 1x
buildFetch, Origin 2x -> 1x
GET without Origin 0x -> 0x (never reached the predicate; unchanged)
The risk here is not the call count, it is that `injected` carries the security headers
onto every response shape — so the tests that matter are the existing ones across
`transport-security`, `http-headers`, `fetch`, `parity` and `web-stream`, all green.
The two new tests assert the count directly, on both adapters, which is the assertion
that keeps it from drifting back.
Closes#77.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
chrnx
merged commit f08956bea8 into develop2026-09-01 14:44:43 +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.
One branch for the whole tier, one commit per issue. All five are in.
Replaces #76, which carried the first commit on a per-issue branch before we settled on a branch per tier.
bb0b01ccors.originspredicate that throws took the process down4896ee8createRequirebannere5d5fb8close()855e044TransformerFnwas not exported, so a custom@Transformercould not be typedb8b3548cors.originspredicate ran two or three times per request#72 and #69 are the published artifact being broken — one exits the process on any cross-origin request, the other kills
@Htmlat boot on Deno and misdiagnoses two more call sites as runtime limitations. #70 was a claim in the README that was not true. #66 was an oversight in the barrel. #77 was found by fixing #72 and was pulled into the tier deliberately, because it lives in the files #72 already touched and ships in the same beta.#72 — deny the origin when the predicate throws
The predicate runs on the request path, above the region where errors convert to a response, so a throw became a rejected promise nobody awaited and Node exited. The guard goes at
originAllowed, the single point all four call sites funnel through. A predicate that throws denies the origin: a lookup that failed has not said yes, and a broken allowlist must never widen into an open one. Reported through the app logger.Converting it to a 500 was the alternative, rejected because two of the four call sites run before any error boundary exists — it would have meant restructuring three of them to gain a worse default.
Verified against the built
dist/with the issue's own reproduction: all four paths that exited code 1 now answer, process alive.Amends one test from the
maxConcurrentRequestscontribution which asserted the old crash as its baseline while proving the gate does not leak a slot. It still proves that.#69 — resolve
requirefrom sourceJSR publishes
src/and runs no bundler, so tsup's banner never existed there.@Html('file')died at boot on Deno withReferenceError: require is not defined; the two guarded sites were worse than the crash, answering confidently and wrongly —staticblamed "edge, no filesystem" while running on Deno, multipart reported busboy missing while it sat innode_modules.All ten call sites now go through one
nodeRequire: the ambientrequirefirst, so the CJS build and the banner-carrying ESM build behave exactly as before, and otherwise one rebuilt fromprocess.getBuiltinModule('node:module')— which Node 22.3+, Deno and Bun all expose synchronously, the actual requirement since every caller sits on a sync path. It resolves fromprocess.cwd(), because a peer dependency belongs to the application, not to a module served over https from a registry. On workerd, where esbuild rewrites the call into its own throwing stub, nothing changes and the guarded sites' "edge has no filesystem" story is finally the true one.The Deno suite already imported
src/exactly as JSR serves it — no test had touched a path that lazily loads a Node builtin, which is how a package that died at boot kept a green suite. It does now, both branches of the shim.#70 —
createApp({ handleSignals: true })Off by default, and that is the design: a library that installs process-wide handlers behind your back is worse than one that installs none. Both halves are supported and documented now — keep the handler, or hand it over. What is not optional either way is that something calls
close(), and the README says so instead of implying the framework had it covered.Declared once on
createApp, wired per runtime by whichever boot call runs:listen(),serveDeno()andserveBun()each pass the closer that drains their server. The returned close unregisters, which on Deno is load-bearing rather than tidy — a liveDeno.addSignalListenerholds the process open.Unregistering first also means a second signal falls through to the platform default and ends the process at once. Deliberate: Ctrl-C twice is the way out of a stuck teardown, and swallowing it for a 10s budget would read as a hang. An orchestrator sends SIGTERM once and then SIGKILL, so it never gets there.
Tested against real processes, because a handler whose job is to exit its own process cannot be fired by hand in the runner. Node covers SIGTERM, SIGINT, the double-signal escape hatch and the default-off case; Deno covers
Deno.addSignalListener/Deno.exit, the API that actually differs. Bun shares Node'sprocesspath and has no signal test of its own — its wiring is the same line as Deno's, which is covered.#66 — export the extension-point types
TransformerFn, plus four more found by checking the barrel for the same shape:PluginApi,ScopeApiandScopeNode(the chain reached throughapi.scope.add, so a plugin split into named functions cannot annotate what it receives),Hooks, andTeardownFn. Types only — nothing at runtime moves. A type test now fails to compile if any of them, or the two that were already exported, leaves the barrel again.#77 — resolve the request's headers once
securityandcorswere computed twice per request and three times for a preflight: once in the adapter, to seed the headers a response written abovehandle()still has to carry, and again indispatch, plus a third time insidecorsPreflightHeaders.Nothing was incorrect — the predicate is expected to be pure with respect to one request. The cost is that
cors.originsis a predicate precisely so it can be a lookup, and the framework charged the caller's latency budget and their backend two to three times for an answer whose inputs did not change in between.handle()now takes the headers the adapter already computed, withcomputeInjectedkept as the fallback for a caller that has none, andcorsPreflightHeadersextends that result. The Node adapter was carrying its own inlined copy ofcomputeInjected; it uses the real one now, which removes the duplicate rather than papering over it.Measured against the built
dist/, same script that produced the numbers in the issue:The risk here is not the call count, it is that
injectedcarries the security headers onto every response shape — so the tests that matter are the existing ones acrosstransport-security,http-headers,fetch,parityandweb-stream. The two new tests assert the count directly on both adapters.One CI failure worth recording
buildwent red on the first push of #70 while everything was green locally. The subprocess tests spawnednpx tsx: macOSnpxexecs into node so the signal reached the app, Linux leaves node a grandchild so SIGTERM landed on the wrapper and the app never heard it. Fixed by spawningprocess.execPath -r tsx/cjsdirectly — no wrapper.-rrather than--import/--loaderbecause it is the one form that works on both the Node 18 floor CI builds against and the current release; verified by installing Node 18 and running all three variants, then running the whole suite under it. Node 18 is now part of the local gate run for this branch.Gates on
b8b3548Not touched, by decision: the version bump to
26.9.0-beta.1and the CHANGELOG both land when the beta is cut, not per PR.requirefrom source, not from tsup's bannerJSR publishes `src/` and runs no bundler, so the `createRequire` banner tsup gives the ESM build (tsup.config.ts) never exists there. Every lazy `require(...)` in the source had nothing to resolve, and one of them was unguarded: `@Html('file')` and template mode died at boot on Deno with `ReferenceError: require is not defined`. The two guarded sites were worse than the crash, because they answered confidently and wrongly. `static` reported *"needs a filesystem and is unavailable on this runtime (edge)"* while running on Deno, which has one; multipart reported busboy as not installed while it sat in node_modules. Both blamed the runtime for a packaging problem, and both named a runtime the reader was not on. Route all ten call sites through one `nodeRequire`, which prefers the ambient `require` — so the CJS build and the banner-carrying ESM build behave exactly as before — and otherwise rebuilds one from `process.getBuiltinModule('node:module')`. Node 22.3+, Deno and Bun all expose that synchronously, which is the requirement: every caller sits on a sync path a dynamic `import()` could not serve. It resolves from `process.cwd()`, since a peer dependency like busboy belongs to the application, not to a module served over https from a registry. Where neither exists — workerd, where esbuild rewrites the call into its own throwing stub — the behaviour is unchanged: the guarded sites still catch, and their "edge has no filesystem" story is finally the true one. Covered by a Deno suite that imports `src/` exactly as JSR serves it. The other Deno tests already did that; none of them touched a path that loads a Node builtin lazily, which is how a package that died at boot kept a green suite. Closes #69. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>The README promised shutdown was *"an extension point, not a SIGTERM handler you write"*. Half of it was true: `dispose()`, `onShutdown` and `hooks` all deliver the *content* of teardown, but nothing called `close()`, so every application still wrote the handler — and wrote it three times, because the spelling is per runtime. Forget it and the container is SIGKILLed after its grace period, every `dispose()` the registry so carefully ordered never runs, and nothing reports it. `createApp({ handleSignals: true })` registers SIGINT/SIGTERM to close and exit. Off by default, and that is the design rather than caution: a library that installs process-wide handlers behind your back is worse than one that installs none, because when the process exits is the application's call. Both halves are now supported and documented — keep the handler, or hand it over. What is not optional either way is that *something* calls `close()`, and the README now says so instead of implying the framework already had it covered. Declared once on `createApp`, wired per runtime by whichever boot call runs: `listen()`, `serveDeno()` and `serveBun()` each pass the closer that drains *their* server to `app.handleSignals`, which returns a close that also unregisters. On Deno that unregistering is load-bearing rather than tidy — a live `Deno.addSignalListener` holds the process open, so an app that closed itself would otherwise hang. Unregistering first also means a *second* signal falls through to the platform default and ends the process at once. That is deliberate: Ctrl-C twice is the way out of a teardown that is stuck, and swallowing it for the length of a 10s budget would read as a hang. An orchestrator sends SIGTERM once and then SIGKILL, so it never gets there. Tested against real processes, because a handler whose job is to exit its own process cannot be fired by hand in the runner: Node covers SIGTERM, SIGINT, the double-signal escape hatch and the default-off case; Deno covers `Deno.addSignalListener`/`Deno.exit`, which is the API that actually differs. Bun shares Node's `process` path. Closes #70. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>10c8262824toe5d5fb801a`Transformer` was exported and `TransformerFn` was not, so a custom transformer could be attached but not typed. The workaround is to borrow the type off a value — `const text: typeof JsonTransformer = ...` — which works and reads like a trick, because it is one. `ErrorRenderer` and `StreamEncoder`, the two neighbouring extension points, were both already exported; this one was an oversight rather than a decision. Checking the rest of the barrel for the same shape turned up four more. A plugin split into named functions rather than one inline arrow cannot annotate what it receives: `Plugin` types the arrow, and `PluginApi`, `ScopeApi` and `ScopeNode` — the chain reached through `api.scope.add`, which is how a plugin contributes to the graph — were all unreachable. So was `Hooks`, which makes `createApp({ hooks })` typeable only inline, and `TeardownFn`, the shape every one of those three doors takes. Types only. Nothing at runtime moves, and no existing export changes. Covered by a type test that fails to compile if any of them leaves the barrel again, including the two that were already there — the failure mode this fixes is a barrel edit nobody notices until a user writes the annotation. Closes #66. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>8b659d827fto855e044d2a`security` and `cors` were computed twice for every request and three times for a preflight: once in the adapter, to seed the headers a response written *above* `handle()` still has to carry — a shed 503, a 413 from the body reader — and again in `dispatch`, plus a third time inside `corsPreflightHeaders`. Nothing was incorrect, because the predicate is expected to be pure with respect to one request. The cost is that `cors.origins` is a predicate precisely so it can be a lookup: an allowlist in Redis, a tenant query. The framework charged the caller's latency budget and their backend two to three times for an answer whose inputs did not change in between, and made a predicate with a counter in it count double. `handle()` now takes the headers the adapter already computed and hands them down, with `computeInjected` kept as the fallback for a caller that has none. `corsPreflightHeaders` extends that result instead of re-deriving it. The Node adapter was carrying its own copy of `computeInjected`, inlined; it uses the real one now, which is what removes the duplicate rather than papering over it. Measured against the built `dist/`, same script that produced the numbers in the issue: GET with Origin 2x -> 1x OPTIONS preflight 3x -> 1x buildFetch, Origin 2x -> 1x GET without Origin 0x -> 0x (never reached the predicate; unchanged) The risk here is not the call count, it is that `injected` carries the security headers onto every response shape — so the tests that matter are the existing ones across `transport-security`, `http-headers`, `fetch`, `parity` and `web-stream`, all green. The two new tests assert the count directly, on both adapters, which is the assertion that keeps it from drifting back. Closes #77. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>