6 Commits
Author SHA1 Message Date
chrnx ed47836c98 Merge pull request 'chore!: require Node 22 and clear dev audit advisories' (#122) from chore/audit-dev-deps into develop
CI / dco (push) Has been skipped
CI / build (push) Successful in 26s
CI / runtimes (deno) (push) Successful in 30s
CI / runtimes (bun) (push) Successful in 14s
CI / runtimes (edge) (push) Successful in 13s
Promote → GitHub / push-github (push) Successful in 6s
2026-10-10 21:41:42 +00:00
chrnx 77a99e83ce chore(deps): vitest 4
CI / runtimes (bun) (pull_request) Successful in 15s
CI / runtimes (deno) (pull_request) Successful in 19s
CI / dco (pull_request) Successful in 4s
CI / build (pull_request) Successful in 26s
CI / runtimes (edge) (pull_request) Successful in 13s
vitest 3.2.7 carried the last three dev audit advisories: tinypool
(critical, prototype pollution to RCE in worker options), vitest itself
(critical, through tinypool and @vitest/mocker) and @vitest/mocker
(moderate, path traversal through a redirected mock). 4.1.11 is the
first stable release outside every affected range; vitest 4 no longer
depends on tinypool at all. It needs Node 20 or newer, which the Node 22
floor now guarantees. vitest 5 would need Node 22.12, and 4.1.11 is
enough to clear the advisories.

vite stays on ^6.4.3, which vitest 4 accepts.

The one change the bump requires: vitest 4 types `vi.fn()` with no
arguments as a mock of a function *or* a constructor, so
`ReturnType<typeof vi.fn>` is no longer callable as a plain function.
listener-boundary.test.ts now types its spies as
`Mock<(...args: unknown[]) => void>`.

npm 10.9 crashes in arborist's #loadPeerSet resolving this tree, so the
lockfile was produced with npm 11.6.2; `npm ci` on Node 22's bundled
npm 10 installs it cleanly.

npm audit: 3 -> 0. npm audit --omit=dev stays at 0.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-10-10 15:03:19 -05:00
chrnx bd478ce09c build!: require Node 22
Node 18 and Node 20 are end-of-life and receive no security patches, so
supporting them before RC.1 would mean promising a runtime nobody can
patch. Node 22 is the oldest line still maintained.

engines.node moves to >=22, @types/node to ^22, the tsup target to
node22, and CI's build job from Node 18 to 22, so every workflow now
runs Node 22 only. The docs, the bug report example and the comments
that stated 18 as the floor follow.

The node:crypto fallback in the HTTP core existed only for Node 18,
which lacked the global crypto; it goes with its regression test, which
said as much. The ws fallback for the WebSocket client stays: Node 22
has the global, but it can still be switched off with a flag.

Moving off Node 18 and 20 also unblocks vitest 4, which the remaining
dev audit advisories need.

BREAKING CHANGE: Node 18 and Node 20 are no longer supported. The
minimum is Node 22.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-10-10 12:10:52 -05:00
chrnx 4c3b4d29c4 chore(deps): move the benchmark's fastify to 5.12.5
CI / dco (pull_request) Successful in 5s
CI / runtimes (bun) (pull_request) Successful in 14s
CI / build (pull_request) Successful in 29s
CI / runtimes (deno) (pull_request) Successful in 19s
CI / runtimes (edge) (pull_request) Successful in 13s
fastify <= 5.12.4 carries seven advisories (high), and it reaches us
twice, both benchmark-only: as a direct devDependency and through
@nestjs/platform-fastify 11.2.7, which pins fastify 5.11.3 exactly.
`npm audit fix --force` would move to @nestjs/platform-fastify 12,
which is ESM-only and needs @nestjs/core and @nestjs/common 12 as
well: a migration of the Nest benchmark servers, not a dependency fix.

Raise the direct range to ^5.12.5, a patch inside the major we already
use, and point nest's copy at it with `"fastify": "$fastify"` so the
tree holds a single, patched fastify.

Checked with `BENCH_SMOKE=1 npm run bench`: fastify, nestjs-fastify
and nestjs-express all boot and serve every scenario with 0% errors.

npm audit: 5 (2 critical, 1 high, 2 moderate) -> 3 (2 critical,
1 moderate), all of them vitest. `npm audit --omit=dev` stays at 0.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-10-10 12:00:06 -05:00
chrnx 445738e830 chore(deps): override miniflare's undici and sharp to patched releases
miniflare 4.20260730.0 is still the newest stable release, and it pins
undici 7.28.0 and sharp 0.35.2. The existing undici 7.29.0 override is
now inside a new advisory range (7.0.0 - 7.29.0, high), and sharp is
under two libheif/librsvg advisories (<= 0.35.5-rc.1, high).
`npm audit fix --force` would install miniflare 5.20261006.1-alpha:
a major and a prerelease, for a test-only dependency.

Move the undici override to 7.29.1 and add sharp 0.35.5, both patch
releases and the exact versions the next miniflare ships with. Same
approach already used for find-my-way, hyperid's uuid and undici.

`test:edge` is the suite that drives workerd through miniflare and it
passes unchanged.

npm audit: 8 (2 critical, 4 high, 2 moderate) -> 5 (2 critical,
1 high, 2 moderate). `npm audit --omit=dev` stays at 0.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-10-10 11:59:59 -05:00
chrnx 352ba477b4 chore(deps): apply non-breaking dev-dependency audit fixes
`npm audit fix` without --force: every bump stays inside the ranges
package.json already declares, so only the lockfile changes.

Clears proxy-addr (critical), multer and @nestjs/platform-express,
qs, brace-expansion, fast-uri, js-yaml and source-map-js. All of them
are dev or benchmark dependencies; `npm audit --omit=dev` was and
stays at 0.

npm audit: 16 (3 critical, 11 high, 2 moderate) -> 8 (2 critical,
4 high, 2 moderate).

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-10-10 11:57:23 -05:00
17 changed files with 431 additions and 601 deletions

No files matched your search

+1 -1
View File
@@ -19,7 +19,7 @@ The smallest module and route that shows it:
## Environment ## Environment
- green-tea version: - green-tea version:
- Runtime and version: <!-- Node 20.11 / Deno 2.1 / Bun 1.1 / Cloudflare Workers --> - Runtime and version: <!-- Node 22.12 / Deno 2.1 / Bun 1.1 / Cloudflare Workers -->
- OS: - OS:
<!-- <!--
+1 -1
View File
@@ -41,7 +41,7 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: '18' node-version: '22'
- run: npm ci - run: npm ci
- run: npm run lint - run: npm run lint
- run: npm run format:check - run: npm run format:check
+5
View File
@@ -10,6 +10,11 @@ npm treats versions as semver and semver forbids leading zeros.
### Breaking ### Breaking
- **Node 18 and Node 20 are no longer supported; the minimum is Node 22.** Both are end-of-life
and receive no security patches, so `engines.node` is now `>=22`, CI runs Node 22 only, and the
build targets `node22`. Node 22 is the oldest line still maintained. The `node:crypto` fallback
for Node 18's missing global `crypto` is removed with it.
- **Inbound WebSocket messages are capped at 1 MiB by default** (#107). Node used `ws`'s own - **Inbound WebSocket messages are capped at 1 MiB by default** (#107). Node used `ws`'s own
default of 100 MiB, and Deno, Bun and the edge applied no cap of their own, so one client could default of 100 MiB, and Deno, Bun and the edge applied no cap of their own, so one client could
make the server hold a message of any size the runtime would accept. A larger message now closes make the server hold a message of any size the runtime would accept. A larger message now closes
+1 -1
View File
@@ -101,7 +101,7 @@ Follow [Conventional Commits](https://www.conventionalcommits.org/): `feat:`, `f
## Local setup ## Local setup
Node 18 or newer, which is what `engines` requires and what CI runs. Node 22 or newer, which is what `engines` requires and what CI runs. Node 18 and 20 are end-of-life and no longer supported.
```bash ```bash
npm install npm install
+1 -1
View File
@@ -284,7 +284,7 @@ green-tea is **beta**, on the road to a release candidate. Express and Fastify h
**What is not here:** no metrics registry, and **no OpenTelemetry exporter in core** — that is a separate package, because core has one runtime dependency and intends to keep it. A `traceparent` header is carried through untouched for an exporter to interpret; core implements no propagation spec. If your definition of production-ready includes shipping traces on day one, you are writing the exporter, and the stream it needs is the part that now exists. **What is not here:** no metrics registry, and **no OpenTelemetry exporter in core** — that is a separate package, because core has one runtime dependency and intends to keep it. A `traceparent` header is carried through untouched for an exporter to interpret; core implements no propagation spec. If your definition of production-ready includes shipping traces on day one, you are writing the exporter, and the stream it needs is the part that now exists.
**Runtimes differ in what they can offer.** Node ≥ 18, Deno, and Bun run everything. On the edge (Cloudflare Workers) there is no `app.listen()`, no filesystem — so `@Html` file/template modes and `static` serving are unavailable — and mesh does not run there at all (the teapot's secret comparison needs `node:crypto`'s `timingSafeEqual`, which `nodejs_compat` doesn't provide). Workers also require the `nodejs_compat` flag. **Runtimes differ in what they can offer.** Node ≥ 22, Deno, and Bun run everything. On the edge (Cloudflare Workers) there is no `app.listen()`, no filesystem — so `@Html` file/template modes and `static` serving are unavailable — and mesh does not run there at all (the teapot's secret comparison needs `node:crypto`'s `timingSafeEqual`, which `nodejs_compat` doesn't provide). Workers also require the `nodejs_compat` flag.
**mesh is alpha.** Distributed DI works, but discovery, load-balancing, and failover are not built, and its API and wire protocol may change between releases. It is gated behind an explicit opt-in — `createApp({ mesh, experimental: true })` — and `createApp` throws if you configure `mesh` without it. Don't ship mesh to production yet. **mesh is alpha.** Distributed DI works, but discovery, load-balancing, and failover are not built, and its API and wire protocol may change between releases. It is gated behind an explicit opt-in — `createApp({ mesh, experimental: true })` — and `createApp` throws if you configure `mesh` without it. Don't ship mesh to production yet.
Generated
+6 -4
View File
@@ -27,7 +27,7 @@
"npm:@types/autocannon@^7.12.7", "npm:@types/autocannon@^7.12.7",
"npm:@types/busboy@^1.5.4", "npm:@types/busboy@^1.5.4",
"npm:@types/express@^5.0.6", "npm:@types/express@^5.0.6",
"npm:@types/node@^18.19.0", "npm:@types/node@^22.20.5",
"npm:@types/ws@^8.18.1", "npm:@types/ws@^8.18.1",
"npm:autocannon@8", "npm:autocannon@8",
"npm:busboy@^1.6.0", "npm:busboy@^1.6.0",
@@ -35,7 +35,7 @@
"npm:esbuild@0.27.2", "npm:esbuild@0.27.2",
"npm:eslint@^9.39.5", "npm:eslint@^9.39.5",
"npm:express@^5.2.1", "npm:express@^5.2.1",
"npm:fastify@^5.11.0", "npm:fastify@^5.12.5",
"npm:graphql@^16.9.0", "npm:graphql@^16.9.0",
"npm:miniflare@^4.20260730.0", "npm:miniflare@^4.20260730.0",
"npm:prettier@^3.9.6", "npm:prettier@^3.9.6",
@@ -46,7 +46,7 @@
"npm:typescript-eslint@^8.65.0", "npm:typescript-eslint@^8.65.0",
"npm:typescript@^5.5.0", "npm:typescript@^5.5.0",
"npm:vite@^6.4.3", "npm:vite@^6.4.3",
"npm:vitest@^3.2.7", "npm:vitest@^4.1.11",
"npm:ws@^8.21.1" "npm:ws@^8.21.1"
], ],
"overrides": { "overrides": {
@@ -56,7 +56,9 @@
"uuid": "11.1.1" "uuid": "11.1.1"
} }
}, },
"undici": "7.29.0" "undici": "7.29.1",
"sharp": "0.35.5",
"fastify": "$fastify"
} }
} }
} }
+387 -525
View File
File diff suppressed because it is too large. Load diff
+7 -5
View File
@@ -26,7 +26,7 @@
"node" "node"
], ],
"engines": { "engines": {
"node": ">=18" "node": ">=22"
}, },
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
@@ -128,7 +128,9 @@
"uuid": "11.1.1" "uuid": "11.1.1"
} }
}, },
"undici": "7.29.0" "undici": "7.29.1",
"sharp": "0.35.5",
"fastify": "$fastify"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.39.5", "@eslint/js": "^9.39.5",
@@ -140,7 +142,7 @@
"@types/autocannon": "^7.12.7", "@types/autocannon": "^7.12.7",
"@types/busboy": "^1.5.4", "@types/busboy": "^1.5.4",
"@types/express": "^5.0.6", "@types/express": "^5.0.6",
"@types/node": "^18.19.0", "@types/node": "^22.20.5",
"@types/ws": "^8.18.1", "@types/ws": "^8.18.1",
"autocannon": "^8.0.0", "autocannon": "^8.0.0",
"busboy": "^1.6.0", "busboy": "^1.6.0",
@@ -148,7 +150,7 @@
"eslint": "^9.39.5", "eslint": "^9.39.5",
"esbuild": "0.27.2", "esbuild": "0.27.2",
"express": "^5.2.1", "express": "^5.2.1",
"fastify": "^5.11.0", "fastify": "^5.12.5",
"graphql": "^16.9.0", "graphql": "^16.9.0",
"miniflare": "^4.20260730.0", "miniflare": "^4.20260730.0",
"prettier": "^3.9.6", "prettier": "^3.9.6",
@@ -158,7 +160,7 @@
"typescript": "^5.5.0", "typescript": "^5.5.0",
"typescript-eslint": "^8.65.0", "typescript-eslint": "^8.65.0",
"vite": "^6.4.3", "vite": "^6.4.3",
"vitest": "^3.2.7", "vitest": "^4.1.11",
"ws": "^8.21.1" "ws": "^8.21.1"
} }
} }
+2 -2
View File
@@ -1513,8 +1513,8 @@ function closeApp(
timeoutMs, timeoutMs,
}); });
// closeAllConnections() requires Node >=18.2, same floor as closeIdleConnections() // closeAllConnections() and closeIdleConnections() below both arrived in Node 18.2;
// below — `engines` in package.json only guarantees >=18, so this matters. // `engines` guarantees >=22, so both are always present.
server.closeAllConnections(); server.closeAllConnections();
finish(); finish();
}, drainBudget); }, drainBudget);
+2 -2
View File
@@ -3,8 +3,8 @@ import { eventSocket, toWsRequest, upgradeSafely, type EventfulSocket } from './
import { closeWithDeadline } from './http/shutdown'; import { closeWithDeadline } from './http/shutdown';
import { setPeer } from './http/peer'; import { setPeer } from './http/peer';
// The project tsconfig's `lib` doesn't include `DOM`, and the installed `@types/node` (18.x) // The project tsconfig's `lib` doesn't include `DOM`, so we ambient-declare just the shape of
// doesn't declare a global `WebSocket` either — so we ambient-declare just the shape we use. // Deno's `WebSocket` we use rather than rely on whichever global `@types/node` happens to declare.
interface WebSocket extends EventfulSocket { interface WebSocket extends EventfulSocket {
binaryType: string; binaryType: string;
} }
+5 -21
View File
@@ -9,31 +9,15 @@ import { acquireBody, type BodyReader } from './body';
import type { RouteDef, HttpOptions } from './types'; import type { RouteDef, HttpOptions } from './types';
import type { StreamEncoder } from '../encoders'; import type { StreamEncoder } from '../encoders';
import type { Bus } from '../bus'; import type { Bus } from '../bus';
import { nodeRequire } from '../node-require';
/** /**
* `randomUUID`, from wherever this runtime keeps it. Resolved once, at import. * `randomUUID` from the web-standard global, which every supported runtime exposes without a flag:
* Node (the `engines` floor is 22; the global arrived unflagged in 19), Deno, Bun and workerd.
* *
* The web-standard global stays the primary path, and that is deliberate rather than stylistic: * Node 18 lacked it, and this used to fall back to `node:crypto` there. That fallback went with the
* this file is the runtime-neutral core, and Deno, Bun and workerd all expose `crypto` without a * Node 18 floor.
* compatibility flag, while `node:crypto` is unavailable to at least one of them.
*
* Node is the exception. The global arrived **unflagged in 19**, and `engines` promises `>=18`,
* where it does not exist at all — so the previous `declare const crypto` compiled cleanly and then
* threw `ReferenceError: crypto is not defined` on the first request of every Node 18 process. Only
* CI's Node 18 job caught it; every newer Node and every other runtime hides it, which is exactly
* why that job is pinned to the floor rather than to the current release.
*
* The fallback is reached only by a runtime that lacks the global, so workerd never evaluates it.
* It goes through {@link nodeRequire} rather than a bare `require`, which is what makes it work on
* every distribution of this package and not just the bundled ones.
*/ */
const randomUUID: () => string = (() => { const randomUUID = (): string => crypto.randomUUID();
const webCrypto = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto;
if (typeof webCrypto?.randomUUID === 'function') return () => webCrypto.randomUUID!();
return nodeRequire<{ randomUUID: () => string }>('node:crypto').randomUUID;
})();
/** /**
* A runtime-neutral inbound request. * A runtime-neutral inbound request.
+4 -2
View File
@@ -124,8 +124,10 @@ export function neutralSocket(
export type SocketCtor = new (url: string) => EventfulSocket; export type SocketCtor = new (url: string) => EventfulSocket;
/** /**
* The WebSocket client implementation: the platform global where it exists (Deno, Bun, and * The WebSocket client implementation: the platform global where it exists, else the `ws`
* Node >= 22), else the `ws` optional peer — Node 18-21, our declared floor, has no global. * optional peer. Every supported runtime has the global — Deno, Bun, and Node from 22, the
* declared floor — so the fallback is reached only when Node runs with the global switched off
* (`--no-experimental-websocket`). `ws` is installed anyway for the server side.
* *
* Both expose the same `addEventListener` API and deliver text frames as `event.data` strings, * Both expose the same `addEventListener` API and deliver text frames as `event.data` strings,
* so one bridge covers both. That is verified rather than assumed: `ws` implements the * so one bridge covers both. That is verified rather than assumed: `ws` implements the
+4 -4
View File
@@ -1,4 +1,4 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { afterEach, beforeEach, describe, expect, it, vi, type Mock } from 'vitest';
import http from 'node:http'; import http from 'node:http';
import net from 'node:net'; import net from 'node:net';
import { once } from 'node:events'; import { once } from 'node:events';
@@ -39,7 +39,7 @@ function get(port: number, path: string, headers: Record<string, string> = {}):
}); });
} }
function spyLogger(): Logger & { error: ReturnType<typeof vi.fn> } { function spyLogger(): Logger & { error: Mock<(...args: unknown[]) => void> } {
return { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() }; return { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() };
} }
@@ -69,8 +69,8 @@ async function expectServerStillServes(port: number): Promise<void> {
const settle = () => new Promise((r) => setTimeout(r, 20)); const settle = () => new Promise((r) => setTimeout(r, 20));
let unhandled: ReturnType<typeof vi.fn>; let unhandled: Mock<(...args: unknown[]) => void>;
let uncaught: ReturnType<typeof vi.fn>; let uncaught: Mock<(...args: unknown[]) => void>;
beforeEach(() => { beforeEach(() => {
unhandled = vi.fn(); unhandled = vi.fn();
+3 -3
View File
@@ -56,11 +56,11 @@ function startSkewedTeapot() {
/** /**
* Both client implementations, exercised on whatever Node runs the suite. `ws` is always in the * Both client implementations, exercised on whatever Node runs the suite. `ws` is always in the
* list: it is the Node 18-21 path, and on a modern CI the platform global would otherwise be the * list: it is the fallback for a Node run with the global WebSocket switched off, and every
* only one ever covered — the fallback would rot unnoticed until someone ran the declared floor. * supported Node has the global, so it would otherwise never be covered and rot unnoticed.
*/ */
const platform = (globalThis as { WebSocket?: SocketCtor }).WebSocket; const platform = (globalThis as { WebSocket?: SocketCtor }).WebSocket;
const CTORS: [string, SocketCtor][] = [['the ws package (Node < 22 path)', WS as unknown as SocketCtor]]; const CTORS: [string, SocketCtor][] = [['the ws package (fallback path)', WS as unknown as SocketCtor]];
if (platform) CTORS.push(['the platform global WebSocket', platform]); if (platform) CTORS.push(['the platform global WebSocket', platform]);
describe('WebSocket client implementations', () => { describe('WebSocket client implementations', () => {
-27
View File
@@ -1,27 +0,0 @@
import { describe, expect, it, vi } from 'vitest';
// The `engines` floor is `>=18`, and the global `crypto` only arrived unflagged in Node 19. That gap
// shipped once: `correlateRequest` compiled cleanly against an ambient declaration and then threw
// `ReferenceError: crypto is not defined` on the first request of every Node 18 process.
//
// CI's Node 18 job is what caught it, and this test is what makes it catchable without one — every
// developer machine and every other runtime has the global, so the bug is invisible where it is
// written. Stubbing the global away reproduces the floor's condition on any Node.
//
// If the floor ever moves above 18, this test and the fallback it guards can both go.
describe('correlateRequest without a global crypto (Node 18)', () => {
it('falls back to node:crypto instead of throwing ReferenceError', async () => {
vi.stubGlobal('crypto', undefined);
vi.resetModules();
const { correlateRequest } = await import('../src/http/core');
const a = correlateRequest({});
const b = correlateRequest({});
expect(a.requestId).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/);
expect(a.requestId).not.toBe(b.requestId);
expect(correlateRequest({ 'x-request-id': 'from-gateway' }).requestId).toBe('from-gateway');
vi.unstubAllGlobals();
});
});
+1 -1
View File
@@ -46,7 +46,7 @@ function runHarness(signal: NodeJS.Signals, env: NodeJS.ProcessEnv = {}, sendTwi
// `process.execPath -r tsx/cjs`, not `npx tsx`: a wrapper puts the app one process further // `process.execPath -r tsx/cjs`, not `npx tsx`: a wrapper puts the app one process further
// down, and on Linux the signal then lands on the wrapper while the app never hears it — which // down, and on Linux the signal then lands on the wrapper while the app never hears it — which
// is exactly how this passed locally and failed in CI. `-r` rather than `--import`/`--loader` // is exactly how this passed locally and failed in CI. `-r` rather than `--import`/`--loader`
// because it is the one form that works on both the Node 18 floor CI builds against and the // because it is the one form that works on both the Node 22 floor CI builds against and the
// current release. // current release.
const proc = spawn(process.execPath, ['-r', 'tsx/cjs', 'test/interop/_signal-app.ts'], { const proc = spawn(process.execPath, ['-r', 'tsx/cjs', 'test/interop/_signal-app.ts'], {
env: { ...process.env, ...env }, env: { ...process.env, ...env },
+1 -1
View File
@@ -9,7 +9,7 @@ export default defineConfig({
dts: true, dts: true,
clean: true, clean: true,
sourcemap: true, sourcemap: true,
target: 'node18', target: 'node22',
// Give the ESM output a real `require` (via createRequire) so the lazy require('ws') / require('busboy') // Give the ESM output a real `require` (via createRequire) so the lazy require('ws') / require('busboy')
// (optional peer deps) resolve instead of hitting esbuild's "Dynamic require not supported" stub. // (optional peer deps) resolve instead of hitting esbuild's "Dynamic require not supported" stub.
esbuildOptions(options, context) { esbuildOptions(options, context) {