Skip to content

Commit 06c2afa

Browse files
fix: break circular dependency causing TUI worker crash
Installation imported Telemetry at the top level, creating a cycle: Installation → Telemetry → Config → ModelsDev → Installation When ModelsDev.refresh() ran at module load time, Installation was still undefined, crashing the TUI worker with: TypeError: undefined is not an object (evaluating 'Installation.USER_AGENT') Fix: use a dynamic import inside upgrade() so Telemetry is only loaded after all modules have fully initialized. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 53625bc commit 06c2afa

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • packages/altimate-code/src/installation

packages/altimate-code/src/installation/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { NamedError } from "@altimateai/altimate-code-util/error"
66
import { Log } from "../util/log"
77
import { iife } from "@/util/iife"
88
import { Flag } from "../flag/flag"
9-
import { Telemetry } from "../telemetry"
109

1110
declare global {
1211
const ALTIMATE_CLI_VERSION: string
@@ -175,6 +174,9 @@ export namespace Installation {
175174
throw new Error(`Unknown method: ${method}`)
176175
}
177176
const result = await cmd.quiet().throws(false)
177+
// Dynamic import breaks the Installation → Telemetry → Config → ModelsDev → Installation
178+
// circular dependency that would cause Installation to be undefined at module load time.
179+
const { Telemetry } = await import("../telemetry")
178180
if (result.exitCode !== 0) {
179181
const stderr = method === "choco" ? "not running from an elevated command shell" : result.stderr.toString("utf8")
180182
const telemetryMethod = (["npm", "bun", "brew"].includes(method) ? method : "other") as "npm" | "bun" | "brew" | "other"

0 commit comments

Comments
 (0)