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>
This commit is contained in:
16 files changed
+39
-75
No files matched your search
@@ -56,11 +56,11 @@ function startSkewedTeapot() {
|
||||
|
||||
/**
|
||||
* 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
|
||||
* only one ever covered — the fallback would rot unnoticed until someone ran the declared floor.
|
||||
* list: it is the fallback for a Node run with the global WebSocket switched off, and every
|
||||
* supported Node has the global, so it would otherwise never be covered and rot unnoticed.
|
||||
*/
|
||||
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]);
|
||||
|
||||
describe('WebSocket client implementations', () => {
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -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
|
||||
// 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`
|
||||
// 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.
|
||||
const proc = spawn(process.execPath, ['-r', 'tsx/cjs', 'test/interop/_signal-app.ts'], {
|
||||
env: { ...process.env, ...env },
|
||||
|
||||
Reference in new issue
Block a user