Skip to content

[Bug]: Renderer crashes with TypeError: Failed to fetch in fetchMessages when background subagent completes #27292

Closed as not planned

Description

@willowite

Description

OpenCode GUI (Electron renderer) crashes with TypeError: Failed to fetch when a background subagent task completes and the parent session tries to fetch updated messages. The crash kills the entire session — no recovery possible without restarting OpenCode.

Environment

  • OpenCode: 1.14.48
  • OmO (oh-my-openagent): 4.1.1
  • OS: Windows 11
  • Model: claude-opus-4-6

Stack trace

TypeError: Failed to fetch
    at fetch (oc://renderer/assets/main-Cb1WDiRx.js:114735:45)
    at request (oc://renderer/assets/main-Cb1WDiRx.js:71162:24)
    at async retry (oc://renderer/assets/main-Cb1WDiRx.js:75706:14)
    at async fetchMessages (oc://renderer/assets/main-Cb1WDiRx.js:77478:24)
    at async loadMessages (oc://renderer/assets/main-Cb1WDiRx.js:77502:7)
    at async Promise.all (index 1)
    at async oc://renderer/assets/main-Cb1WDiRx.js:77660:13

Reproduction

  1. Start OpenCode TUI/GUI
  2. In a session, spawn a background task:
task(subagent_type="explore", load_skills=[], run_in_background=true,
     prompt="Return exactly: TEST")
  1. Wait for <system-reminder> notification that task completed
  2. Renderer crashes with the above stack trace
  3. Session is lost

Observations

  • The crash happens in fetchMessages → loadMessages — the renderer tries to fetch messages from the completed child session but the fetch fails
  • Backend logs (~/.local/share/opencode/log/) do NOT contain TypeError or Failed to fetch — this is purely renderer-side
  • The crash is intermittent but frequent (observed multiple times in one session)
  • Backend background task infrastructure works correctly — the task completes, result is available via API. The crash is in the UI layer consuming the completion event

Possibly related

Suggested investigation

The fetchMessages call in the renderer likely races with the session lifecycle — the child session may be cleaned up or rotated before the renderer's loadMessages call resolves. A guard or retry with session-existence check before fetch could prevent the crash.

Activity

  1. cy574 commented on May 14, 2026

    @cy574

    Same issue here. Can confirm this reproduces with as few as 3 concurrent background agents (not just high concurrency). The /ohmy-opencode-agent-tester skill is a one-click reproducible case.

    Test results by concurrency level — all crash:

    14 agents → crash
    6 agents → crash
    3 agents → crash
    This suggests the issue is not load-dependent but rather a missing backpressure/throttle mechanism in fetchMessages itself.

    Env: OpenCode 1.4.49, Windows 11 Pro 64-bit (Build 10.0.26200),OmO (oh-my-openagent): 4.1.1

  2. github-actions commented on Jul 14, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions