Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion packages/core/src/util/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function isTransientError(error: unknown): boolean {
}

export async function retry<T>(fn: () => Promise<T>, options: RetryOptions = {}): Promise<T> {
const { attempts = 3, delay = 500, factor = 2, maxDelay = 10000, retryIf = isTransientError } = options
const { attempts = 5, delay = 1000, factor = 2, maxDelay = 30000, retryIf = isTransientError } = options

let lastError: unknown
for (let attempt = 0; attempt < attempts; attempt++) {
Expand Down
6 changes: 5 additions & 1 deletion packages/sdk/js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ function rewrite(request: Request, directory?: string) {
export function createOpencodeClient(config?: Config & { directory?: string }) {
if (!config?.fetch) {
const customFetch: any = (req: any) => {
// Use a 5-minute timeout instead of disabling it entirely.
// Disabling the timeout causes fetch to hang forever when the backend
// becomes unresponsive, leading to unrecoverable "Failed to fetch" errors
// in the renderer (see #28702).
// @ts-ignore
req.timeout = false
req.timeout = 300_000
return fetch(req)
}
config = {
Expand Down
6 changes: 5 additions & 1 deletion packages/sdk/js/src/v2/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ function rewrite(request: Request, values: { directory?: string; workspace?: str
export function createOpencodeClient(config?: Config & { directory?: string; experimental_workspaceID?: string }) {
if (!config?.fetch) {
const customFetch: any = (req: any) => {
// Use a 5-minute timeout instead of disabling it entirely.
// Disabling the timeout causes fetch to hang forever when the backend
// becomes unresponsive, leading to unrecoverable "Failed to fetch" errors
// in the renderer (see #28702).
// @ts-ignore
req.timeout = false
req.timeout = 300_000
return fetch(req)
}
config = {
Expand Down
Loading