Skip to content

[Critical] Fix memory leak in fire-and-forget promises #5

Description

@randomm

Problem

In packages/opencode/src/core/loop.ts (line 376) and stream.ts (line 456), persistThinking().catch() creates unbounded promise queue without tracking.

Impact

Application crash under load when many thinking blocks persist.

Solution

Either:

  1. Await the promise
  2. Track with BackgroundTasks
  3. Use bounded task queue

Files

  • packages/opencode/src/core/loop.ts
  • packages/opencode/src/core/stream.ts

Branch

claude/simplify-agentic-loop-2jRSP

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions