Skip to content

Commit fe94700

Browse files
authored
fix(cli,core,webapp): flag legacy Node deployments for runtime updates (#4865)
1 parent 8142a11 commit fe94700

5 files changed

Lines changed: 57 additions & 13 deletions

File tree

apps/webapp/app/routes/_app.orgs.$organizationSlug.settings.projects/route.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NODE_RUNTIME_UPDATE_MAJOR } from "@trigger.dev/core/v3";
1+
import { needsNodeRuntimeUpdate } from "@trigger.dev/core/v3";
22
import { typedjson, useTypedLoaderData } from "remix-typedjson";
33
import { resolveOrgIdFromSlugForUser } from "~/models/organization.server";
44
import { listCurrentProductionProjectRuntimes } from "~/services/projectRuntimeUpdates.server";
@@ -54,7 +54,7 @@ export const loader = dashboardLoader(
5454
: null,
5555
};
5656

57-
if (deployment?.nodeMajor === NODE_RUNTIME_UPDATE_MAJOR) {
57+
if (deployment && needsNodeRuntimeUpdate(deployment.runtime, deployment.runtimeVersion)) {
5858
needsUpdate.push(row);
5959
} else {
6060
otherProjects.push(row);

apps/webapp/app/services/projectRuntimeUpdates.server.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ export async function listCurrentProductionProjectRuntimes(scope: Scope) {
8585
);
8686
}
8787

88-
/**
89-
* Whether any project in the organization runs the reported Node.js major in Production.
90-
*
91-
* The SQL filter mirrors `nodeMajor(runtime, runtimeVersion) === NODE_RUNTIME_UPDATE_MAJOR`, which
92-
* the page applies in JS: keep the two in step. Scoped to the caller's membership so the side menu
93-
* cannot report on an organization the user does not belong to.
94-
*/
9588
export async function organizationHasProjectRuntimeUpdate({
9689
organizationSlug,
9790
userId,
@@ -115,8 +108,20 @@ export async function organizationHasProjectRuntimeUpdate({
115108
some: {
116109
label: CURRENT_DEPLOYMENT_LABEL,
117110
deployment: {
118-
runtime: { startsWith: "node" },
119-
runtimeVersion: { startsWith: `${NODE_RUNTIME_UPDATE_MAJOR}.` },
111+
OR: [
112+
{
113+
runtimeVersion: { startsWith: `${NODE_RUNTIME_UPDATE_MAJOR}.` },
114+
OR: [{ runtime: null }, { runtime: { startsWith: "node" } }],
115+
},
116+
{
117+
runtimeVersion: null,
118+
OR: [
119+
{ runtime: null },
120+
{ runtime: "node" },
121+
{ runtime: `node-${NODE_RUNTIME_UPDATE_MAJOR}` },
122+
],
123+
},
124+
],
120125
},
121126
},
122127
},

packages/cli-v3/src/commands/projects/list.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { intro, outro } from "@clack/prompts";
2-
import { NODE_RUNTIME_UPDATE_MAJOR } from "@trigger.dev/core/v3";
2+
import { needsNodeRuntimeUpdate, NODE_RUNTIME_UPDATE_MAJOR } from "@trigger.dev/core/v3";
33
import type { Command } from "commander";
44
import { z } from "zod";
55
import { CliApiClient } from "../../apiClient.js";
@@ -70,7 +70,11 @@ async function listProjects(options: ProjectsListCommandOptions) {
7070
}
7171

7272
const projects = options.needsUpdate
73-
? response.data.filter((project) => project.deployment?.nodeMajor === NODE_RUNTIME_UPDATE_MAJOR)
73+
? response.data.filter(
74+
(project) =>
75+
project.deployment &&
76+
needsNodeRuntimeUpdate(project.deployment.runtime, project.deployment.runtimeVersion)
77+
)
7478
: response.data;
7579

7680
if (projects.length === 0) {

packages/core/src/v3/schemas/api-type.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { describe, it, expect } from "vitest";
22
import {
33
BatchItemNDJSON,
44
InitializeDeploymentRequestBody,
5+
needsNodeRuntimeUpdate,
56
nodeMajor,
67
TriggerTaskRequestBody,
78
} from "./api.js";
@@ -21,6 +22,22 @@ describe("nodeMajor", () => {
2122
});
2223
});
2324

25+
describe("needsNodeRuntimeUpdate", () => {
26+
it.each([
27+
["node", "21.7.3", true],
28+
[null, "21.7.3", true],
29+
["node", null, true],
30+
[null, null, true],
31+
["node-21", null, true],
32+
["node-22", null, false],
33+
["node-22", "22.16.0", false],
34+
["node", "unknown", false],
35+
["bun", "1.3.3", false],
36+
])("classifies %s %s", (runtime, runtimeVersion, expected) => {
37+
expect(needsNodeRuntimeUpdate(runtime, runtimeVersion)).toBe(expected);
38+
});
39+
});
40+
2441
describe("InitializeDeploymentRequestBody", () => {
2542
const base = { contentHash: "abc123" };
2643

packages/core/src/v3/schemas/api.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,24 @@ export function nodeMajor(
7979
return match ? Number(match[1]) : undefined;
8080
}
8181

82+
export function needsNodeRuntimeUpdate(
83+
runtime: string | null | undefined,
84+
runtimeVersion: string | null | undefined
85+
) {
86+
if (runtime && !runtime.startsWith("node")) return false;
87+
88+
const versionMatch = runtimeVersion?.match(/^(\d+)(?:\.\d+){1,2}(?:[-+].*)?$/);
89+
if (versionMatch) return Number(versionMatch[1]) === NODE_RUNTIME_UPDATE_MAJOR;
90+
if (runtimeVersion) return false;
91+
92+
if (!runtime || runtime === "node") return true;
93+
94+
const configuredMajorMatch = runtime.match(/^node-(\d+)$/);
95+
return configuredMajorMatch
96+
? Number(configuredMajorMatch[1]) === NODE_RUNTIME_UPDATE_MAJOR
97+
: false;
98+
}
99+
82100
export const GetProjectRuntimesResponseBody = z.array(
83101
z.object({
84102
organization: z.object({

0 commit comments

Comments
 (0)