Skip to content

Commit a511019

Browse files
anandgupta42claude
andcommitted
fix: [#309] bound upgradeCurl fetch with 15s timeout
Address CodeRabbit review feedback on PR #825: the install-script `fetch` in `Installation.upgradeCurl()` had no timeout, so a stalled CDN/origin could hang `altimate upgrade` indefinitely. Wrap the request with `AbortSignal.timeout(15_000)` so it fails fast. - `packages/opencode/src/installation/index.ts` — add `signal: AbortSignal.timeout(15_000)` to the fetch options; keep inside the existing `altimate_change` block (now gates URL + timeout together). - `packages/opencode/test/install/upgrade-method.test.ts` — new regression assertion that the source still contains the bounded timeout. The other CodeRabbit comment (refactor `_telemetryCache` to `Effect.cached`) is outside this PR's diff and unrelated to the install URL fix — leaving it for a separate change. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent 4614e6e commit a511019

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎packages/opencode/src/installation/index.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ export namespace Installation {
3434
}
3535

3636
async function upgradeCurl(target: string) {
37-
// altimate_change start — curl-upgrade endpoint URL
37+
// altimate_change start — curl-upgrade endpoint URL + bounded fetch timeout
3838
// Upstream uses opencode.ai/install. We fetch the altimate install script
3939
// from www.altimate.sh/install (the apex altimate.sh isn't routed to the
4040
// Amplify Next.js app — tracked separately; revisit when apex DNS is fixed).
41-
const body = await fetch("https://www.altimate.sh/install").then((res) => {
41+
// 15s timeout so a stalled CDN/origin can't hang `altimate upgrade` forever.
42+
const body = await fetch("https://www.altimate.sh/install", {
43+
signal: AbortSignal.timeout(15_000),
44+
}).then((res) => {
4245
if (!res.ok) throw new Error(res.statusText)
4346
return res.text()
4447
})

‎packages/opencode/test/install/upgrade-method.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ describe("upgrade execution", () => {
9797
expect(INSTALLATION_SRC).not.toContain("https://altimate.ai/install")
9898
})
9999

100+
test("curl upgrade fetch has a bounded timeout", () => {
101+
// Without a timeout the install-script fetch can stall indefinitely on a
102+
// hung CDN/origin, blocking `altimate upgrade` forever. Use AbortSignal.timeout
103+
// so the request fails fast with a clear error instead.
104+
expect(INSTALLATION_SRC).toMatch(/AbortSignal\.timeout\(\s*15_000\s*\)/)
105+
})
106+
100107
test("VERSION normalization strips v prefix", () => {
101108
expect(INSTALLATION_SRC).toContain('OPENCODE_VERSION.trim().replace(/^v/, "")')
102109
})

0 commit comments

Comments
 (0)