Skip to content

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

@willowite

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 fetchMessagesloadMessages — 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.

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