From 312fa3b31afb17628d5ce145d398b3a98f18e0c1 Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Thu, 23 Jul 2026 12:25:48 -0700 Subject: [PATCH] fix(server): parse CLI version in update preflight --- apps/server/src/cloud/selfUpdate.test.ts | 4 ++-- apps/server/src/cloud/selfUpdate.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/server/src/cloud/selfUpdate.test.ts b/apps/server/src/cloud/selfUpdate.test.ts index 28bcc0ffe62..9d6e3801704 100644 --- a/apps/server/src/cloud/selfUpdate.test.ts +++ b/apps/server/src/cloud/selfUpdate.test.ts @@ -54,7 +54,7 @@ const makeRecordingRunnerLayer = ( return { stdout: options?.stdoutFor?.(input.command, input.args) ?? - (versionFromPath === undefined ? "" : `${versionFromPath}\n`), + (versionFromPath === undefined ? "" : `t3 v${versionFromPath}\n`), stderr: failed ? `${input.command} exploded` : "", code: ChildProcessSpawner.ExitCode(failed ? 1 : 0), timedOut: false, @@ -427,7 +427,7 @@ it.layer(NodeServices.layer)("ServerSelfUpdate.update", (it) => { Effect.gen(function* () { const context = yield* makeContext({ stdoutFor: (command, args) => - command === NODE_PATH && args[1] === "--version" ? "0.0.28\n" : undefined, + command === NODE_PATH && args[1] === "--version" ? "t3 v0.0.28\n" : undefined, }); const versionDir = context.path.join(context.baseDir, "runtime", "versions", "0.0.29"); diff --git a/apps/server/src/cloud/selfUpdate.ts b/apps/server/src/cloud/selfUpdate.ts index 2df49910bd5..62bd07fbbc8 100644 --- a/apps/server/src/cloud/selfUpdate.ts +++ b/apps/server/src/cloud/selfUpdate.ts @@ -273,8 +273,10 @@ export const make = Effect.fn("cloud.server_self_update.make")(function* (option failWith(`Could not verify the installed t3@${targetVersion}.`, cause), ), ); - const preflightVersion = preflight.stdout.trim(); - if (preflight.code !== 0 || preflightVersion !== targetVersion) { + // Effect CLI's unstable formatVersion currently emits `${name} v${version}`. + // Extract the version token so surrounding presentation changes do not break updates. + const reportedVersion = /\bv(\S+)\s*$/.exec(preflight.stdout)?.[1]; + if (preflight.code !== 0 || reportedVersion !== targetVersion) { // A completed npm install can still be unusable under this Node or on // this machine. Remove its sentinel and tree so a retry of the same // version performs a clean install instead of reusing a known-bad one.