Skip to content

rpc: client leaks pending promises forever when postMessage throws (terminate window, dead thread) #397

Closed

Description

@mdev34-lab

Severity: high | global review pass P3.

packages/opencode/src/util/rpc.ts:112-113: call() does pending.set(id,{resolve,reject}) then target.postMessage(...) with no try/catch. WorkerPostMessageTarget.postMessage (worker-process.ts:154, if(!current) throw) and the thread-worker path (:268-269, postMessage after terminate/thread death) throw synchronously. The pending entry is never removed nor rejected; target.onclose only runs after process exit, so the caller hangs forever. Headless run.ts awaits background.wait that never resolves; the TUI's createWorkerFetch hangs - looks like a freeze.

Repro: await worker.terminate() then client.call("fetch", ...), or fire a request in the crash-restart window when current===undefined; the pending Map grows and the promise never settles. Fix size: small (try/catch around postMessage; on throw pending.delete(id); reject(error)).

Activity

  1. agenteinstinct1-max commented on Oct 21, 2026

    @agenteinstinct1-max
    Collaborator

    Fixed by #446 (merged into dev-vibecoded).

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

Metadata

Metadata

Assignees

No one assigned

    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