Skip to content

[BUG] Network error with error ID not retried (z.ai / GLM 5.1) #31133

@lele872

Description

@lele872

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions