Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/opencode/src/global/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ if (version !== CACHE_VERSION) {
}),
),
)
} catch (e) {}
await Bun.file(path.join(Global.Path.cache, "version")).write(CACHE_VERSION)
await Bun.file(path.join(Global.Path.cache, "version")).write(CACHE_VERSION)
} catch (e) {
// Log to stderr since Log module may not be initialized yet (circular dependency)
console.error("[global] failed to clear cache:", e instanceof Error ? e.message : String(e))
}
}
4 changes: 2 additions & 2 deletions packages/opencode/src/mcp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,11 +812,11 @@ export namespace MCP {
await new Promise<void>((resolve, reject) => {
// Give the process a moment to fail if it's going to
const timeout = setTimeout(() => resolve(), 500)
subprocess.on("error", (error) => {
subprocess.once("error", (error) => {
clearTimeout(timeout)
reject(error)
})
subprocess.on("exit", (code) => {
subprocess.once("exit", (code) => {
if (code !== null && code !== 0) {
clearTimeout(timeout)
reject(new Error(`Browser open failed with exit code ${code}`))
Expand Down
2 changes: 1 addition & 1 deletion packages/opencode/src/session/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export namespace SessionRetry {
if (json.type === "error" && json.error?.code?.includes("rate_limit")) {
return "Rate Limited"
}
return JSON.stringify(json)
return undefined
} catch {
return undefined
}
Expand Down
5 changes: 1 addition & 4 deletions packages/opencode/src/util/timeout.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
export function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T> {
let timeout: NodeJS.Timeout
return Promise.race([
promise.then((result) => {
clearTimeout(timeout)
return result
}),
promise.finally(() => clearTimeout(timeout)),
new Promise<never>((_, reject) => {
timeout = setTimeout(() => {
reject(new Error(`Operation timed out after ${ms}ms`))
Expand Down
4 changes: 2 additions & 2 deletions packages/opencode/test/session/retry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ describe("session.retry.retryable", () => {
expect(SessionRetry.retryable(error)).toBe("Provider is overloaded")
})

test("handles json messages without code", () => {
test("returns undefined for json messages without known retryable patterns", () => {
const error = wrap(JSON.stringify({ error: { message: "no_kv_space" } }))
expect(SessionRetry.retryable(error)).toBe(`{"error":{"message":"no_kv_space"}}`)
expect(SessionRetry.retryable(error)).toBeUndefined()
})

test("does not throw on numeric error codes", () => {
Expand Down
Loading