Skip to content

bug: InterruptError — All fibers interrupted when InstanceStore.dispose races with Agent.list #32755

Closed as not planned

Description

@liuxb99

Describe the bug

When an HTTP request triggers Agent.list (which reads agent configuration from the filesystem via ScopedCache.get), and at the same time another request triggers InstanceStore.dispose, the ScopedCache invalidation interrupts all in-flight lookup fibers, producing InterruptError: All fibers interrupted without error.

This error propagates up to the HTTP response and reaches the Telegram Bot as a session.promptAsync failure.

Stack trace

InterruptError: All fibers interrupted without error
    at FileSystem.up (B:/~BUN/root/chunk-pcf2w4yn.js:2:18581)
    at FileSystem.up (definition) (B:/~BUN/root/chunk-ewqah108.js:16:23248)
    at Agent.state (B:/~BUN/root/chunk-ae5jadfy.js:2:4743)
    at Agent.state (definition) (B:/~BUN/root/chunk-10rcnd8y.js:171:805)
    at Agent.list (B:/~BUN/root/chunk-nv7cdy3k.js:2:207057)
    at Agent.list (definition) (B:/~BUN/root/chunk-10rcnd8y.js:171:5293)
    at InstanceHttpApi.agent (B:/~BUN/root/chunk-nv7cdy3k.js:2:79248)
    at InstanceHttpApi.agent (definition) (B:/~BUN/root/chunk-nv7cdy3k.js:2:207000)
    at Server.listen (B:/~BUN/root/chunk-nv7cdy3k.js:3:46713)
    at Server.listen (definition) (B:/~BUN/root/chunk-nv7cdy3k.js:3:46836)

Root cause

1. Race condition in InstanceState.make + disposeMiddleware

packages/opencode/src/effect/instance-state.ts line 38 registers a disposer that invalidates the ScopedCache when the instance is disposed. If a concurrent HTTP request is in the middle of Agent.list → ScopedCache.get → lookup → Agent.state (reading files via FileSystem.up), the invalidation closes the Effect scope and interrupts all child fibers.

2. Unhandled InterruptError in Agent.list

packages/opencode/src/agent/agent.ts lines 357-358:

list: Effect.fn("Agent.list")(function* () {
    return yield* InstanceState.useEffect(state, (s) => s.list())
})

InterruptError propagates unhandled through InstanceHttpApi.agent to the HTTP response.

Affected files

  • packages/opencode/src/effect/instance-state.ts (lines 30-39) — ScopedCache with disposer that interrupts in-flight lookups
  • packages/opencode/src/agent/agent.ts (lines 357-358) — Agent.list without InterruptError handling
  • packages/opencode/src/server/routes/instance/httpapi/lifecycle.ts (lines 43-53) — disposeMiddleware triggers teardown while requests are in-flight

Suggested fix

  1. In Agent.list (agent.ts:357), catch InterruptError and retry or return a degraded response
  2. Consider using Effect.uninterruptible for the ScopedCache lookup to prevent disposal from interrupting in-flight requests

Activity

  1. github-actions commented on Aug 17, 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