Description
Using z.ai (GLM 5.1) provider via OpenCode Go, sessions consistently fail with a "Network error" containing an error ID, instead of being retried.
Exact error message:
Network error, error id: 2026060622490410eb8ceede9541e9, please try again later
Context:
- Provider: z.ai (GLM 5.1) via OpenCode Go
- OpenCode version: 1.16.2 (installed via Homebrew)
- OS: macOS (Darwin arm64)
- Error occurs during provider API requests
- Session terminates immediately without any retry attempt
Root cause (from source analysis):
In packages/opencode/src/session/message-v2.ts, the fromError() function only classifies ECONNRESET as retryable (isRetryable: true). The error above (and similar transient network errors like ETIMEDOUT, ENOTFOUND, EAI_AGAIN, ECONNREFUSED, EHOSTUNREACH, ENETUNREACH, EPIPE, fetch failed, socket hang up, terminated, other side closed) fall through to the generic Error case, creating an UnknownError which is not retried by the retry logic in retry.ts.
Related issues:
Expected behavior:
Transient network errors should be classified as retryable and the session should automatically retry with exponential backoff.
Workaround tested locally:
Modified fromError() to include all transient system error codes and text patterns as APIError(isRetryable: true). This allows the existing retry mechanism to handle them correctly.
Environment
- OpenCode: 1.16.2
- OS: macOS (Darwin arm64)
- Provider: z.ai (GLM 5.1) via OpenCode Go
- Installation: Homebrew
Description
Using z.ai (GLM 5.1) provider via OpenCode Go, sessions consistently fail with a "Network error" containing an error ID, instead of being retried.
Exact error message:
Context:
Root cause (from source analysis):
In
packages/opencode/src/session/message-v2.ts, thefromError()function only classifiesECONNRESETas retryable (isRetryable: true). The error above (and similar transient network errors likeETIMEDOUT,ENOTFOUND,EAI_AGAIN,ECONNREFUSED,EHOSTUNREACH,ENETUNREACH,EPIPE,fetch failed,socket hang up,terminated,other side closed) fall through to the genericErrorcase, creating anUnknownErrorwhich is not retried by the retry logic inretry.ts.Related issues:
Expected behavior:
Transient network errors should be classified as retryable and the session should automatically retry with exponential backoff.
Workaround tested locally:
Modified
fromError()to include all transient system error codes and text patterns asAPIError(isRetryable: true). This allows the existing retry mechanism to handle them correctly.Environment