Skip to content

fix: prevent hang when plugin calls client.app.log() during init#1

Closed
kdcokenny wants to merge 1 commit intodevfrom
fix/plugin-init-hang
Closed

fix: prevent hang when plugin calls client.app.log() during init#1
kdcokenny wants to merge 1 commit intodevfrom
fix/plugin-init-hang

Conversation

@kdcokenny
Copy link
Owner

Background

This fix is ported from upstream anomalyco/opencode PR #11642.

Bug Description

A circular dependency causes an infinite hang when a plugin calls client.app.log() during initialization:

  1. Plugin initialization starts
  2. Plugin calls client.app.log() during init
  3. The /log route is hit
  4. Instance.provide middleware runs
  5. InstanceBootstrap tries to initialize plugins
  6. Loop back to step 1 → infinite recursion/hang

The Fix

Skip the Instance.provide middleware for the /log endpoint. This breaks the circular dependency chain since logging operations no longer trigger instance/plugin initialization.

The /log endpoint doesn't require instance-specific context, so this is a safe optimization that prevents the hang without affecting functionality.

Skip Instance.provide middleware for /log endpoint to break circular
dependency: plugin init → client.app.log() → /log route → Instance.provide
→ InstanceBootstrap → plugin init → infinite loop

Ported from upstream PR #11642
@kdcokenny kdcokenny closed this Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant