feat: migrate to Node 24 LTS#481
Conversation
… 24, drop node-fetch
…e with import.meta, fix Express 5 param types
There was a problem hiding this comment.
Pull request overview
This PR migrates the service to Node.js 24 LTS, leveraging newer Node runtime features (built-in fetch, import.meta.dirname/import.meta.filename) and removing now-unneeded compatibility helpers/dependencies.
Changes:
- Bump runtime/CI expectations to Node 24 (
.nvmrc, GitHub Actions,package.json#engines). - Replace
node-fetchand legacyimport.metapath helpers with Node’s built-infetchandimport.meta.dirname/import.meta.filename. - Adjust Express 5 route param typing and add tests for Node 24 globals and
PROJECT_ROOT.
Reviewed changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/misc.ts | Removes legacy dirname/filename helpers and related imports. |
| utils/constants.ts | Uses import.meta.dirname to compute PROJECT_ROOT. |
| utils/background-task-queue.ts | Switches worker bootstrap path to import.meta.filename. |
| scripts/update-w3c-groups-list.ts | Drops node-fetch/fileURLToPath usage; uses global fetch and import.meta.filename. |
| app.ts | Uses import.meta.dirname for views path. |
| routes/xref/update.ts | Uses import.meta.dirname for worker path. |
| routes/caniuse/update.ts | Uses import.meta.dirname for worker path. |
| routes/well-known/pay.ts | Removes node-fetch import (uses global fetch). |
| routes/w3c/group.ts | Adjusts Express 5 param typing; sets plain-text content type on invalid type. |
| routes/github/commits.ts | Adjusts Express 5 param typing and query typing; ensures plain-text in error path. |
| routes/github/contributors.ts | Adjusts Express 5 param typing. |
| routes/github/lib/utils/rest.ts | Removes node-fetch types; adds GitHub API URL validation; updates header typing. |
| routes/github/lib/utils/graphql.ts | Removes node-fetch import (uses global fetch). |
| routes/docs/update.ts | Removes node-fetch import (uses global fetch). |
| tests/node24-globals.test.js | Adds test assertions for Node 24 globals (fetch, import.meta.dirname, import.meta.filename). |
| tests/utils/constants.test.js | Adds coverage for PROJECT_ROOT resolution. |
| package.json | Adds Node >=24 engines constraint; removes node-fetch dependency. |
| pnpm-lock.yaml | Removes node-fetch and its transitive dependencies. |
| .nvmrc | Updates local Node version to 24. |
| .github/workflows/test.yml | Adds/updates CI to run on Node 24. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
routes/github/lib/utils/rest.ts:53
x-ratelimit-resetis a Unix timestamp in seconds, butnew Date(number)expects milliseconds. As written,resetAtwill be ~1000× earlier than intended, which can break any rate-limit/backoff logic that relies onresetAt. Convert the header value to milliseconds before constructing theDate.
function getRateLimit(headers: Headers): RateLimit {
return {
remaining: parseInt(headers.get("x-ratelimit-remaining") as string, 10),
resetAt: new Date(parseInt(headers.get("x-ratelimit-reset") as string, 10)),
limit: parseInt(headers.get("x-ratelimit-limit") as string, 10),
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Agent-Logs-Url: https://github.com/speced/respec-web-services/sessions/5e94febe-bb8b-4d99-86e6-050ffa3f7cb0 Co-authored-by: marcoscaceres <870154+marcoscaceres@users.noreply.github.com>
|
@copilot, see @sidvishnoi's suggestions. Can you make the changes and also rebase? |
Applied @sidvishnoi’s suggestions in |
|
@copilot Can you fix the ci issue? |
Fixed in |
There was a problem hiding this comment.
Does some lib in tsconfig not support it? Or updating @types/node?
Fine this way as well.
Closes #373
Summary
.nvmrcand CI to Node 24 LTS"engines": { "node": ">=24" }topackage.jsonnode-fetchdependency — replaced with the Node 24 built-infetchlegacyDirname(import.meta)/legacyFilename(import.meta)helpers (and theirfileURLToPathplumbing) withimport.meta.dirname/import.meta.filename(available since Node 21.2)legacyDirnameandlegacyFilenameexports fromutils/misc.tsreq.paramstype errors (TS2345) incommits.ts,contributors.ts, andgroup.tsfetch,import.meta.dirname, andimport.meta.filenameare available as globals, and thatPROJECT_ROOTresolves correctlyNote
This PR touches some of the same files as #480 (the security hardening PR). It should be merged after #480 to avoid conflicts.