-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(runtime): add experimental Node.js 24 and 26 task runtimes #4085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
carderne
wants to merge
11
commits into
main
Choose a base branch
from
feature/tri-11473-modernise-user-runtimes-add-node-24-default-for-new-add-node
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
53b88bb
feat(runtime): add node-24/node-26, deprecate node(21), default new p…
carderne caf4b63
fix(runtime): keep node as the default runtime
carderne 3cb2ff0
feat(runtime): add experimental Node.js 24 and 26 runtimes
carderne bc38c3c
fix(runtime): gate new Node runtimes behind experimental aliases
carderne 0ea5f74
feat: scope RuntimeDefault seccomp profile to node-24+ run pods
carderne 5cc6840
refactor: use targeted io_uring seccomp profile instead of RuntimeDef…
carderne 35eff67
disable for self-hosters
carderne dfaa0e5
chore: shorten comments in kubernetesPodSpec.ts
carderne b3b1af9
reduce comments
carderne fda0f49
delete another comment
carderne 90867d7
format
carderne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@trigger.dev/core": patch | ||
| "trigger.dev": patch | ||
| --- | ||
|
|
||
| Add experimental Node.js 24 and 26 task runtimes. Set `runtime` to `experimental-node-24` or `experimental-node-26` in `trigger.config.ts`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { | ||
| BLOCK_IO_URING_SECCOMP_PROFILE, | ||
| withBlockIoUringSeccompProfile, | ||
| } from "./kubernetesPodSpec.js"; | ||
|
|
||
| const basePodSpec = { | ||
| restartPolicy: "Never" as const, | ||
| automountServiceAccountToken: false, | ||
| securityContext: { | ||
| runAsNonRoot: true, | ||
| runAsUser: 1000, | ||
| fsGroup: 1000, | ||
| }, | ||
| }; | ||
|
|
||
| describe("withBlockIoUringSeccompProfile", () => { | ||
| it("adds the Localhost io_uring profile for node-24 and above, preserving pod security defaults", () => { | ||
| for (const runtime of ["node-24", "node-26", "node-30", "experimental-node-24"]) { | ||
| const podSpec = withBlockIoUringSeccompProfile(basePodSpec, runtime); | ||
|
|
||
| expect(podSpec).toMatchObject({ | ||
| ...basePodSpec, | ||
| securityContext: { | ||
| ...basePodSpec.securityContext, | ||
| seccompProfile: { | ||
| type: "Localhost", | ||
| localhostProfile: BLOCK_IO_URING_SECCOMP_PROFILE, | ||
| }, | ||
| }, | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| it("leaves the pod spec unchanged for runtimes that do not create io_uring fds", () => { | ||
| for (const runtime of ["node", "node-22", "bun", undefined, null, ""]) { | ||
| expect(withBlockIoUringSeccompProfile(basePodSpec, runtime)).toEqual(basePodSpec); | ||
| } | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import type { k8s } from "../clients/kubernetes.js"; | ||
|
|
||
| /** | ||
| * Relative path (kubelet seccomp root) of the profile blocking only io_uring | ||
| * syscalls. Must match the profile deployed to worker nodes. | ||
| */ | ||
| export const BLOCK_IO_URING_SECCOMP_PROFILE = "profiles/block-io-uring.json"; | ||
|
|
||
| /** | ||
| * Node >= 24 always creates io_uring fds, which can't be checkpointed. Blocking | ||
| * io_uring_setup makes libuv fall back to epoll. Other runtimes don't need this, | ||
| * so the profile is only applied for node-24+. Tolerates an "experimental-" prefix. | ||
| */ | ||
| export function withBlockIoUringSeccompProfile( | ||
| podSpec: Omit<k8s.V1PodSpec, "containers">, | ||
| runtime: string | null | undefined | ||
| ): Omit<k8s.V1PodSpec, "containers"> { | ||
| const match = runtime ? /^(?:experimental-)?node-(\d+)$/.exec(runtime) : null; | ||
| if (!match || Number(match[1]) < 24) { | ||
| return podSpec; | ||
| } | ||
|
|
||
| return { | ||
| ...podSpec, | ||
| securityContext: { | ||
| ...podSpec.securityContext, | ||
| seccompProfile: { | ||
| type: "Localhost", | ||
| localhostProfile: BLOCK_IO_URING_SECCOMP_PROFILE, | ||
| }, | ||
| }, | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises"; | ||
| import { tmpdir } from "node:os"; | ||
| import { join } from "node:path"; | ||
| import { afterEach, describe, expect, it } from "vitest"; | ||
| import { loadConfig } from "./config.js"; | ||
|
|
||
| const projectDirs: string[] = []; | ||
|
|
||
| afterEach(async () => { | ||
| await Promise.all(projectDirs.splice(0).map((dir) => rm(dir, { recursive: true, force: true }))); | ||
| }); | ||
|
|
||
| async function createProject(runtime?: string) { | ||
| const cwd = await mkdtemp(join(tmpdir(), "trigger-runtime-config-")); | ||
| projectDirs.push(cwd); | ||
|
|
||
| await mkdir(join(cwd, "trigger")); | ||
| await writeFile(join(cwd, "package.json"), JSON.stringify({ name: "runtime-config-test" })); | ||
| await writeFile(join(cwd, "pnpm-lock.yaml"), "lockfileVersion: '9.0'\n"); | ||
| await writeFile( | ||
| join(cwd, "trigger.config.ts"), | ||
| `export default { | ||
| project: "proj_runtime_config_test", | ||
| maxDuration: 60, | ||
| dirs: ["./trigger"], | ||
| ${runtime === undefined ? "" : `runtime: ${JSON.stringify(runtime)},`} | ||
| }; | ||
| ` | ||
| ); | ||
|
|
||
| return cwd; | ||
| } | ||
|
|
||
| describe("loadConfig runtime", () => { | ||
| it.each([ | ||
| ["experimental-node-24", "node-24"], | ||
| ["experimental-node-26", "node-26"], | ||
| ] as const)("normalizes %s before returning the resolved config", async (runtime, expected) => { | ||
| const cwd = await createProject(runtime); | ||
|
|
||
| await expect(loadConfig({ cwd, warn: false })).resolves.toMatchObject({ runtime: expected }); | ||
| }); | ||
|
|
||
| it("keeps node as the default", async () => { | ||
| const cwd = await createProject(); | ||
|
|
||
| await expect(loadConfig({ cwd, warn: false })).resolves.toMatchObject({ runtime: "node" }); | ||
| }); | ||
|
|
||
| it.each(["node-24", "node-26", "node-23"])( | ||
| "rejects unsupported public runtime %s while loading config", | ||
| async (runtime) => { | ||
| const cwd = await createProject(runtime); | ||
|
|
||
| await expect(loadConfig({ cwd, warn: false })).rejects.toThrowError( | ||
| new RegExp(`Unsupported runtime "${runtime}" in trigger\\.config`) | ||
| ); | ||
| } | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import type { BuildRuntime } from "@trigger.dev/core/v3/schemas"; | ||
| import { describe, expect, it } from "vitest"; | ||
| import { generateContainerfile } from "./buildImage.js"; | ||
|
|
||
| const nodeImages: Array<[BuildRuntime, string]> = [ | ||
| [ | ||
| "node-24", | ||
| "node:24.18.0-bookworm-slim@sha256:6f7b03f7c2c8e2e784dcf9295400527b9b1270fd37b7e9a7285cf83b6951452d", | ||
| ], | ||
| [ | ||
| "node-26", | ||
| "node:26.4.0-bookworm-slim@sha256:ec82d089a8ae2cf02628da7b34ea57dc357b24db724d557fe2d240e6beb659c1", | ||
| ], | ||
| ]; | ||
|
|
||
| describe("generateContainerfile", () => { | ||
| it.each(nodeImages)("selects the pinned multiplatform image for %s", async (runtime, image) => { | ||
| const containerfile = await generateContainerfile({ | ||
| runtime, | ||
| build: {}, | ||
| image: undefined, | ||
| indexScript: "index.js", | ||
| entrypoint: "entrypoint.js", | ||
| }); | ||
|
|
||
| expect(containerfile).toContain(`FROM ${image} AS base`); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.