From 3cc9319aabe7d7d726479280666508ac1d42d2cb Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Thu, 12 Mar 2026 10:10:46 +0900 Subject: [PATCH] feat: end support Node.js v18 --- .github/workflows/ci.yml | 2 +- README.md | 8 +------- package.json | 2 +- src/globals.ts | 6 ------ src/listener.ts | 1 - src/request.ts | 4 ++-- 6 files changed, 5 insertions(+), 18 deletions(-) delete mode 100644 src/globals.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fd4c24..3442aea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: - node-version: [18.x, 20.x, 22.x, 24.x] + node-version: [20.x, 22.x, 24.x] steps: - uses: actions/checkout@v4 diff --git a/README.md b/README.md index af0e931..d9fdf5d 100644 --- a/README.md +++ b/README.md @@ -38,13 +38,7 @@ Statistics Avg Stdev Max ## Requirements -It works on Node.js versions greater than 18.x. The specific required Node.js versions are as follows: - -- 18.x => 18.14.1+ -- 19.x => 19.7.0+ -- 20.x => 20.0.0+ - -Essentially, you can simply use the latest version of each major release. +It works on Node.js versions greater than 20.x. ## Installation diff --git a/package.json b/package.json index 92c4508..1637f71 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "access": "public" }, "engines": { - "node": ">=18.14.1" + "node": ">=20" }, "devDependencies": { "@hono/eslint-config": "^1.0.1", diff --git a/src/globals.ts b/src/globals.ts deleted file mode 100644 index 421c8da..0000000 --- a/src/globals.ts +++ /dev/null @@ -1,6 +0,0 @@ -import crypto from 'node:crypto' - -/** jest dose not use crypto in the global, but this is OK for node 18 */ -if (typeof global.crypto === 'undefined') { - global.crypto = crypto as Crypto -} diff --git a/src/listener.ts b/src/listener.ts index 83603bf..de57142 100644 --- a/src/listener.ts +++ b/src/listener.ts @@ -20,7 +20,6 @@ import { buildOutgoingHttpHeaders, } from './utils' import { X_ALREADY_SENT } from './utils/response/constants' -import './globals' const outgoingEnded = Symbol('outgoingEnded') type OutgoingHasOutgoingEnded = Http2ServerResponse & { diff --git a/src/request.ts b/src/request.ts index ea34768..26400ed 100644 --- a/src/request.ts +++ b/src/request.ts @@ -34,8 +34,8 @@ export class Request extends GlobalRequest { } // Check if body is ReadableStream like. This makes it compatbile with ReadableStream polyfills. if (typeof (options?.body as ReadableStream)?.getReader !== 'undefined') { - // node 18 fetch needs half duplex mode when request body is stream - // if already set, do nothing since a Request object was passed to the options or explicitly set by the user. + // Half duplex mode is required when request body is a stream. + // If already set, do nothing since a Request object was passed to the options or explicitly set by the user. ;(options as any).duplex ??= 'half' } super(input, options)