Repository navigation
feat!: add Node.js 24 support and remove Node.js 20 - #565
Conversation
FNA-1642 `node24` was added as a deploy runtime and made the default in #555, and the local Node version check already accepts Node 24, but `engines.node` was left at `^20.x || ^22.x`. The toolkit therefore defaulted to deploying to node24 while refusing to declare support for running on Node 24, so users on Node 24 saw engine warnings. Widen the range to `^20.x || ^22.x || ^24.x` across the four published packages. The plugins depend on `twilio-run`, so bumping only `twilio-run` would leave them blocking Node 24 — all four move together. Fixes #563. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 5962840 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
FNA-1642 Node.js 20 is deprecated on Twilio Serverless and can no longer be used for new builds, so drop it from the supported range in the same change that adds Node.js 24. - `engines.node` becomes `^22.x || ^24.x` in the four published packages - the scaffolded project template's engines range follows suit - the local version check no longer accepts Node 20 - `.nvmrc`, CONTRIBUTING and the serverless-twilio-runtime Readme move to the new minimum, and the on-merge-main workflow builds on Node 22 Mirrors the Node.js 18 removal in #544. BREAKING CHANGE: Projects using create-twilio-function, plugin-assets, plugin-serverless, serverless-twilio-runtime or twilio-run will have to migrate to Node.js 22 or 24. Fixes #563. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
FNA-1642 Removing node20 from the supported range does not help existing projects whose .twilioserverlessrc still pins "runtime": "node20" — the CLI keeps sending it and the build fails at the platform with no local hint as to why. Add a `checkForDeprecatedRuntime` check, run from `twilio-run deploy`, that warns when the resolved runtime is not one of node22/node24 and points at the config field to change. It warns rather than fails: the platform remains the authority on which runtimes it accepts, and an unset runtime stays silent. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
| * supported by Twilio Serverless. Deprecated runtimes are rejected for new | ||
| * builds, so this surfaces the problem before the deploy fails. | ||
| */ | ||
| export function checkForDeprecatedRuntime(runtime?: string): boolean { |
There was a problem hiding this comment.
Wouldn't there be a risk of divergence if someone is using toolkit programmatically and doesn't update to the latest version where supported runtimes are changed?
There was a problem hiding this comment.
It sounds like it should be checked server-side?
There was a problem hiding this comment.
e.g. when we add node26, the toolkit will tell users their valid runtime "is not supported" Worth double-checking this scenario.
There was a problem hiding this comment.
We can invert and use a denylist instead of allowlist, we don't need to keep it updated in order to allow new runtimes, if a runtime is deprecated it will be checked server-side anyways, so keeping it updated is less critical
FNA-1642 Review feedback: an allow list of supported runtimes baked into the CLI diverges from the platform as soon as a new runtime is added. A project pinned to an older toolkit would tell users their valid node26 config "is not supported" — the client confidently contradicting the platform. Invert both checks to deny lists of deprecated versions. A deprecation is a settled fact, so an outdated deny list stays correct: at worst it misses a newer deprecation and the platform rejects the build as it would have anyway. Unknown and future values are left alone. - `deprecated-runtime.ts` lists every even major up to 20 and no longer warns on unrecognised runtime values - `nodejs-version.ts` compares the local major against the same list instead of an allow list of supported versions - `printVersionWarning` drops its now-unused expectedVersion parameter - add the missing test coverage for `checkNodejsVersion` Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
FNA-1642 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Odd majors are Current-only and EOL in ~8 months, but people stay on them ( A floor fits the local check better: const LOWEST_SUPPORTED_NODE_MAJOR = 22;
if (major < LOWEST_SUPPORTED_NODE_MAJOR) {
printVersionWarning(nodeVersion);
}No gaps, still silent on newer versions, one number to maintain. Worth adding |
Fixes #563 · FNA-1642 · epic FNA-947 Node20 Deprecation
Warning
BREAKING CHANGE. Projects using
create-twilio-function,@twilio-labs/plugin-assets,@twilio-labs/plugin-serverless,@twilio-labs/serverless-twilio-runtimeortwilio-runwill have to migrate to Node.js 22 or 24.Problem
Three facets of the same inconsistency:
node24as a deploy runtime and made it the default (packages/twilio-run/src/templating/defaultConfig.ts), and added24.to the local version check, but it never touched anyenginesfield. The toolkit defaulted to deploying to node24 while refusing to declare support for running on Node 24, so Node 24 users saw engine warnings ([FEATURE] [twilio-run] NodeJS 24 support #563)..twilioserverlessrcpins"runtime": "node20"keeps sending node20 —serverless-api/src/api/builds.tsforwards whatever is configured — and the build is rejected at the platform with no local hint as to why.Change
engines.nodegoes from^20.x || ^22.xto^22.x || ^24.x.enginesin the four published packagespackages/{twilio-run,create-twilio-function,plugin-serverless,plugin-assets}/package.jsonenginesrangepackages/create-twilio-function/src/create-twilio-function/versions.jspackages/twilio-run/src/checks/deprecated-runtime.ts, wired intosrc/commands/deploy.tspackages/twilio-run/src/checks/nodejs-version.ts.nvmrc→ 22,docs/CONTRIBUTING.mdpackages/serverless-twilio-runtime/Readme.md.github/workflows/on-merge-main.yml→ Node 22The Node version work mirrors the Node.js 18 removal in #544 — same file set, same
majorchangeset shape, including@twilio-labs/serverless-twilio-runtimeso the Node support policy stays aligned across the packages.#563 named only
twilio-run, but the plugins depend on it, so all packages move together rather than leavingplugin-serverlessandplugin-assetsbehind.Deploy-time warning
checkForDeprecatedRuntimeruns duringtwilio-run deployand warns when the configured runtime is a deprecated one:Deliberately a warning, not a failure: Twilio Serverless stays the authority on which runtimes it accepts, so the CLI surfaces the problem earlier without pre-emptively blocking a deploy.
Deny list, not allow list
Per review feedback from @alfrol and @jannoteelem — an allow list of supported runtimes baked into the CLI diverges from the platform as soon as a new runtime is added. A project pinned to an older toolkit would tell users their perfectly valid
node26config "is not supported", i.e. the client confidently contradicting the platform. Both checks therefore use one shared deny list of deprecated versions:node26)A deprecation is a settled fact, so an outdated deny list stays correct; its worst case is a missing hint, where the allow list's worst case is a false claim. The supported set, by contrast, only ever grows, so an allow list would need a release per Node version forever.
Two consequences worth calling out for reviewers:
nodejs-version.tshad the same defect before this PR (SERVERLESS_NODE_JS_VERSIONwas an allow list, so a stale toolkit would warn at anyone on local Node 26). It now compares the local major against the same shared deny list. As a result it no longer warns on odd/non-LTS versions such as 19, 21 or 23 — an intentional trade for not being wrong about future versions.printVersionWarningdrops its now-unusedexpectedVersionparameter. It is not exported from the package'smain/typesentry point (src/index.tsonly exportshandlerToExpressRouteandrunDevServer) and no package in the monorepo imports it, so this is only reachable via an unsupported deep import — and this is amajorrelease.Unknown or unrecognised runtime values are now left entirely to the platform, rather than the CLI guessing.
Node 24 is already the default runtime (
DEFAULT_RUNTIME = 'node24', written as an active line into generated.twilioserverlessrcfiles), so no change was needed there.Testing
npx jest packages/twilio-run— 207 passed, 25 suites, 4 snapshotsnpx jest packages/create-twilio-function— 61 passed, 9 suitesnpx tsc --noEmitinpackages/twilio-run— clean__tests__/checks/deprecated-runtime.test.ts— every deprecated runtime warns, the list is pinned to the expected even majors, supported runtimes stay silent, future runtimes (node26/node28/node30) stay silent, unset and unrecognised values stay silent, and the check never exits the process__tests__/checks/nodejs-version.test.ts— this check previously had no test coverage at all; now covers deprecated local versions warning, supported ones staying silent, and future ones (26/28) staying silentnpx changeset status --since=origin/main— major bump for exactly the five intended packages, nothing at patch/minorCHANGELOG.mdentriesThe test matrix in
nodejs.ymlis[lts/-1, lts/*], which tracks 22 and 24 — no matrix change needed.🤖 Generated with Claude Code