Skip to content

Sidecar crashes (exit code 1) after first request since v4.1.1 update #3997

Closed

Description

@ThomasChangX

Bug Summary

After upgrading to [email protected], the sidecar process crashes with exit code 1 immediately after processing the first successful request. All subsequent requests fail with "failed to fetch" because the sidecar is no longer running.

Pattern: First request → succeeds ✅ → sidecar crashes 💥 → all following requests → "failed to fetch" ❌

Environment

  • OpenCode Desktop: v1.14.48 (macOS arm64)
  • oh-my-openagent: v4.1.1 (auto-updated from npm via "plugin": ["oh-my-openagent@latest"])
  • @opencode-ai/plugin: v1.14.48
  • @opencode-ai/sdk: v1.14.48
  • Platform: macOS Darwin (Apple Silicon M-series)
  • Node.js sidecar: Uses oh-my-openagent-darwin-arm64 binary

Regression Evidence

The package was auto-updated at 2026-05-13 22:42:29 UTC+8. Sidecar crashes began immediately after:

Time Event Exit Code
22:42:21 Sidecar normal exit (before update) 0 ✅
22:42:29 package-lock.json updated → v4.1.1 installed —
22:42:24 New sidecar spawned —
22:44:17 First crash after update 1 ❌
22:45:32 Crash 1 ❌
22:46:26 Crash (only ~20s uptime) 1 ❌
... All subsequent exits are code 1 1 ❌

Before this update, all sidecar exits were code: 0 (normal).

Sidecar Log Pattern

From ~/Library/Logs/@opencode-ai/desktop/main.log:

[2026-05-14 00:13:41.285] [info]  sidecar connection started { url: 'http://127.0.0.1:53922' }
[2026-05-14 00:13:41.286] [info]  spawning sidecar { url: 'http://127.0.0.1:53922' }
[2026-05-14 00:13:41.606] [warn]  sidecar stderr { message: '(node:72159) ExperimentalWarning: SQLite is an experimental feature...' }
[2026-05-14 00:13:42.326] [info]  server ready { url: 'http://127.0.0.1:53922' }
[2026-05-14 00:14:31.128] [warn]  sidecar exited { code: 1 }   ← ~49s uptime, after first request

The sidecar starts successfully, serves one request, then crashes.

Config

~/.config/opencode/opencode.json (relevant section):

{
  "plugin": ["oh-my-openagent@latest"]
}

~/.config/opencode/oh-my-openagent.json (model config):

{
  "agents": {
    "sisyphus": { "model": "zai-coding-plan/glm-5.1" },
    "oracle": { "model": "zai-coding-plan/glm-5.1" },
    "explore": { "model": "minimax-cn/MiniMax-M2.7" },
    "librarian": { "model": "minimax-cn/MiniMax-M2.7" }
  },
  "categories": {
    "quick": { "model": "minimax-cn/MiniMax-M2.7" },
    "deep": { "model": "zai-coding-plan/glm-5.1" }
  }
}

Connected providers: openrouter, minimax-cn, zai-coding-plan, deepseek, opencode

MCP servers configured: MiniMax (local), zai-vision (local), plus 3 disabled remote MCPs.

Steps to Reproduce

  1. Install OpenCode Desktop v1.14.48
  2. Configure oh-my-openagent@latest as plugin (resolves to v4.1.1)
  3. Start OpenCode → sidecar spawns successfully
  4. Send first chat message → receives response correctly
  5. Send second chat message → "failed to fetch" error
  6. Observe sidecar has exited with code 1 in logs

Workaround

Locking to the previous version avoids the crash:

{
  "plugin": ["[email protected]"]
}

Then clear the cached package:

rm -rf ~/.cache/opencode/packages/oh-my-openagent@latest

Additional Notes

  • No crash reports generated in ~/Library/Logs/DiagnosticReports/
  • No proxy configured (HTTP_PROXY/HTTPS_PROXY unset)
  • NO_PROXY=127.0.0.1,localhost,::1
  • The SQLite experimental warning appears on every sidecar start (likely unrelated but noting for completeness)
  • The sidecar process (oh-my-openagent-darwin-arm64) is a Mach-O 64-bit ARM64 binary wrapping Node.js
  • Source dist/index.js contains process.exit() (bare, no code) at one location, plus killProcessGroup signal handlers — the crash may originate from an unhandled rejection or signal handler

Activity

  1. UncleXJ commented on May 14, 2026

    @UncleXJ

    Windows 11 reproduction (same symptoms)

    I can confirm this issue on Windows 11 with:

    • OpenCode Desktop: v1.14.50
    • oh-my-openagent: v4.1.2 (manually installed via npm tarball)
    • Platform: Windows 11 (x64)

    Same Pattern

    First request succeeds, then sidecar crashes with exit code 1. Every subsequent request fails with connection error until sidecar auto-restarts.

    Timeline (main.log)

    [16:54:03] server ready
    [16:58:29] sidecar exited { code: 1 }  // ~4 min after first request
    

    Root Cause Analysis

    I traced through the OMO source code and found the crash mechanism:

    1. src/features/background-agent/process-cleanup.ts registers error handlers:

      cleanupErrorHandlers.set(uncaughtException, registerErrorEvent(uncaughtException, cleanupAll));
      cleanupErrorHandlers.set(unhandledRejection, registerErrorEvent(unhandledRejection, cleanupAll));

    egisterErrorEvent calls scheduleForcedExit(handler(error), 1, true) which eventually calls process.exit(1)

    1. The underlying uncaught exception is likely AbortError from OpenCode's session.processor - see [BUG]:session.processor crashes sidecar on unhandled AbortError anomalyco/opencode#26667

    Corroborating Evidence

    Workaround

    Rolling back to v4.0.0 resolves the crash (but loses tolerantFsyncSync needed for NTFS junctions on Windows).

  2. yanxiaodong2026-debug commented on May 14, 2026

    @yanxiaodong2026-debug

    我现在回滚到4.0.0执行复杂任务还是会出现,方便留个联系方式联系一下吗

  3. UncleXJ commented on May 14, 2026

    @UncleXJ
  4. UncleXJ commented on May 15, 2026

    @UncleXJ

    Temporary Workaround (Local Patch)

    Until this is fixed upstream, we patched registerErrorEvent in dist/index.js to suppress AbortError and TypeError from triggering process.exit(1):

    `javascript
    // In registerErrorEvent listener (around line 111618)
    const listener = (error) => {
    process.off(signal, listener);
    console.error('[OMO-CRASH-DEBUG] ' + signal + ' caught:', error?.message || error);

    // --- PATCH START: suppress known non-fatal errors ---
    if (error?.name === 'AbortError') {
    log('warn', [OMO] Suppressing AbortError (OpenCode session.processor known issue #26667));
    return; // Don't exit
    }
    if (error instanceof TypeError) {
    log('warn', [OMO] Suppressing TypeError: );
    return; // Don't exit - e.g. ctx.$ is not a function
    }
    // --- PATCH END ---

    log('error', [OMO] :, error);
    scheduleForcedExit(handler(error), 1, true);
    };
    `

    This prevents the two known crash paths:

    1. ctx.$ is not a function (TypeError) in sendSessionNotification / playSessionNotificationSound
    2. AbortError from OpenCode session.processor (issue #26667)

    Both are non-fatal errors that should not cause a sidecar crash.

    Note: This patch must be reapplied after every OMO update since it modifies dist/index.js directly.

  5. nieaowei commented on May 15, 2026

    @nieaowei

    Temporary Workaround (Local Patch)

    Until this is fixed upstream, we patched registerErrorEvent in dist/index.js to suppress AbortError and TypeError from triggering process.exit(1):

    `javascript // In registerErrorEvent listener (around line 111618) const listener = (error) => { process.off(signal, listener); console.error('[OMO-CRASH-DEBUG] ' + signal + ' caught:', error?.message || error);

    // --- PATCH START: suppress known non-fatal errors --- if (error?.name === 'AbortError') { log('warn', [OMO] Suppressing AbortError (OpenCode session.processor known issue #26667)); return; // Don't exit } if (error instanceof TypeError) { log('warn', [OMO] Suppressing TypeError: ); return; // Don't exit - e.g. ctx.$ is not a function } // --- PATCH END ---

    log('error', [OMO] :, error); scheduleForcedExit(handler(error), 1, true); }; `

    This prevents the two known crash paths:

    1. ctx.$ is not a function (TypeError) in sendSessionNotification / playSessionNotificationSound
    2. AbortError from OpenCode session.processor (issue #26667)

    Both are non-fatal errors that should not cause a sidecar crash.

    Note: This patch must be reapplied after every OMO update since it modifies dist/index.js directly.

    Good way.

  6. code-yeongyu commented on May 16, 2026

    @code-yeongyu
    Owner

    [sisyphus-bot]

    Confirmed. Current dev still contains the fatal paths described in this report, so this should stay open as a real process-lifecycle bug/regression. I assigned code-yeongyu because the fix needs an owner decision on which errors are safe to suppress versus which should still terminate the sidecar.

    Code evidence:

    • src/features/background-agent/process-cleanup.ts:70-86 registers global uncaughtException / unhandledRejection listeners and routes both through scheduleForcedExit(handler(error), 1, true).
    • src/features/background-agent/process-cleanup.ts:39-52 sets process.exitCode, starts a forced-exit timer, and calls process.exit(exitCode) after cleanup when exitAfterCleanup is true.
    • src/features/background-agent/process-cleanup.ts:140-149 only skips these global error handlers when OMO_DISABLE_PROCESS_CLEANUP is set; there is no built-in suppression for non-fatal AbortError or notification-related TypeError.
    • src/hooks/session-notification-sender.ts:51-105 still calls ctx.$ directly for desktop notification commands. If the Desktop sidecar/plugin context lacks a valid shell helper, that can throw TypeError and flow into the same global fatal-exit handler.

    This matches the user reports across macOS and Windows: a first request can succeed, then a later unhandled rejection/exception path can terminate the sidecar with exit code 1. The linked local workaround that suppresses AbortError and TypeError is consistent with the code, but the real fix should be more deliberate than catching every TypeError globally.

    Recommended fix direction:

    • Treat known non-fatal OpenCode aborts separately from true plugin crashes.
    • Harden session notification execution so a missing/mis-shaped ctx.$ cannot crash the process.
    • Add regression coverage proving AbortError and notification shell-helper failures do not force-exit, while genuinely fatal cleanup errors still remain observable.

    Labels applied: bug, confirmed, triage:bug.
    Assignee added: code-yeongyu for the process-lifecycle policy decision.

  7. added
    bugSomething isn't working
    confirmedBug confirmed / reproducible
    triage:bugConfirmed bug with repro steps
    on May 16, 2026
  8. self-assigned this
    on May 16, 2026
  9. 97lj commented on May 16, 2026

    @97lj

    在oh-my-openagent.jsonc配置里"disabled_hooks": ["session-notification"]即可,只是关闭了系统通知,不影响核心功能,这样OMO更新也不需要重新打补丁

  10. UncleXJ commented on May 16, 2026

    @UncleXJ

    Thanks to @97lj for the disabled_hooks: ["session-notification"] workaround! On macOS + Windows Desktop with OMO v4.1.2, this prevents the sidecar crash.

    Question: what does disabling session-notification affect? Any lost functionality or side effects?

  11. 97lj commented on May 16, 2026

    @97lj

    暂时没发现有什么副作用,使用AI分析的结果,崩溃发生在 registerErrorEvent → sendSessionNotification,因为 ctx.$ 不存在。这是通知系统内部的 bug,不影响任何核心功能。sendSessionNotification的功能是发送系统托盘通知(会话完成/错误/需要输入),禁用 session-notification 等于关掉了一个纯装饰性的通知功能,对实际使用零影响。目前我使用上是正常的,在opencode 1.15.0和1.15.3上使用正常。

  12. mguttmann commented on May 17, 2026

    @mguttmann

    Filed a separate issue #4120 with the macOS arm64 napi_fatal_error / SIGABRT stack trace (top frames: node::OnFatalError → napi_fatal_error → callbackEventsToJS → Napi::ThreadSafeFunction::CallJS), and submitted a PR as #4122.

    Important caveat to other reporters here: my PR addresses a different code path than the ctx.$ is not a function / session-notification-sender.ts root cause that @code-yeongyu's bot identified above. The disabled_hooks: ["session-notification"] workaround from @97lj is probably more effective for the notification-path crashes. My fix targets a parent-wake race in flushPendingParentWake where dispatchInternalPrompt and a fresh user message land on the same session-storage file within the watcher's batch window — that triggers a napi_fatal_error in @parcel/watcher's TSFN callback when the session view has just re-mounted.

    So there are likely two distinct crash paths producing the same "exit code 1" symptom:

    1. ctx.$ undefined in notification sender (covered by disabled_hooks workaround, needs the deeper fix the bot suggested)
    2. Parent-wake collision with fresh user message → watcher TSFN race (addressed by fix(background-agent): defer parent-wake when a user message just arrived (fixes #4120) #4122)

    Both should ideally be fixed. If you're hitting this and disabled_hooks: ["session-notification"] does not stop the crash for you, the parent-wake race in #4122 may be your variant — happy to compare DiagnosticReports.

  13. code-yeongyu commented on May 18, 2026

    @code-yeongyu
    Owner

    [sisyphus-bot] Status update

    Both crash paths in this issue are now being addressed:

    Path 2 — Parent-wake race against @parcel/watcher TSFN (the napi_fatal_error / SIGABRT variant on macOS arm64 documented in #4120):

    Path 1 — ctx.$ is not a function TypeError from session-notification-sender:

    • One thing my earlier triage got wrong: src/features/background-agent/process-cleanup.ts was already rewritten log-only on dev (the uncaughtException / unhandledRejection listeners now log + return, they do not call scheduleForcedExit anymore — see commit history on that file). So the process.exit(1) path I described above is gone from dev; what shipped in v4.1.x still has it, which is why users on the published binary still see exit code 1, while users on a freshly-built dev see the TypeError logged but the host stays alive.
    • A separate PR is in flight that adds the missing defensive guard at the source: sendSessionNotification and playSessionNotificationSound will return early when typeof ctx?.$ !== "function", so the TypeError is never thrown in the first place. That eliminates the symptom on both dev and (once published) for users on the released binary.

    For users currently affected on a published version:

    • The disabled_hooks: ["session-notification"] workaround from @97lj remains the cleanest mitigation until the next release.
    • If you can build from dev locally, the v4.2.0 line already contains the process-cleanup log-only rewrite, so the sidecar will no longer exit on the TypeError even before the source-side guard lands.

    This issue will be closed once the source-side guard PR merges. Tracking under @sisyphus-bot.

  14. added a commit that references this issue on May 18, 2026
  15. code-yeongyu commented on May 18, 2026

    @code-yeongyu
    Owner

    [sisyphus-bot] Resolved on dev. All three crash paths in this issue are now addressed.

    Path Symptom Fix Commit on dev
    Parent-wake race vs @parcel/watcher TSFN napi_fatal_error / SIGABRT (mostly macOS arm64, per #4120) #4122 — defer flushPendingParentWake while a fresh user message is still being processed; unref() long-lived bookkeeping timers 6037b917 (merge), source 329412827
    Global uncaughtException → scheduleForcedExit(1, true) Sidecar exits code 1 after any transient streaming rejection Previously rewritten log-only — registerErrorEvent now detaches the listener and only logs (describeProcessCleanupError). No more process.exit(1) from transient rejections. Already on current dev; predates this triage. (already on dev before this issue)
    TypeError: ctx.$ is not a function from sendSessionNotification / playSessionNotificationSound Sidecar exits code 1 immediately after the first successful request on v4.1.x (where the force-exit path still exists) #4127 — added canRunNotificationCommand guard that checks typeof ctx?.$ === "function" before invoking the shell helper. Logs once on first observation, returns early after that. Both notification + sound paths covered. c4dd21e1 (merge), source 397ed1048

    Status:

    • dev currently contains all three fixes.
    • Published npm (v4.1.2, 4.0.0) still ships path 2 and path 3 unguarded — users on those versions will keep hitting the crash until the next release.
    • Until then, disabled_hooks: ["session-notification"] (the workaround from @97lj) remains the cleanest mitigation. Rolling back to 4.0.0 is not necessary if the workaround is acceptable.

    Verification:

    Closing this issue. A new release is needed to ship these fixes to users on v4.1.x. If you reproduce the crash on a build from current dev, please reopen with a fresh ~/Library/Logs/DiagnosticReports/ entry and the oh-my-opencode.log tail.

    Thanks to @ThomasChangX for the original report, @UncleXJ for the Windows reproduction + workaround patch, @97lj for the disabled_hooks workaround, and @mguttmann for #4122 / the parent-wake race analysis.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingconfirmedBug confirmed / reproducibletriage:bugConfirmed bug with repro steps

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions