GeezerVison is showing github.com — Plugin Hanging When Using client.app.log() During Initialization · Issue #7741 · anomalyco/opencode
Plugin Hanging When Using client.app.log() During Initialization #7741
Labels
bugSomething isn't working Description
Description
What proper implementations and/or workarounds do you suggest without busying the simplest code?
Issue Summary
OpenCode plugins hang indefinitely when calling client.app.log() during plugin initialization, preventing OpenCode from starting properly.
Environment
- OpenCode version: Latest (as of Jan 2025)
- Plugin API: @opencode-ai/[email protected]
- Platform: macOS (Darwin)
Reproduction Steps
- Create a plugin that calls
client.app.log() during initialization
- Place plugin in
.opencode/plugin/ directory
- Start OpenCode
- OpenCode hangs immediately after "loading plugin" message
Expected Behavior
Plugin should load successfully and logging calls should work without hanging.
Actual Behavior
OpenCode hangs indefinitely during plugin initialization at the first client.app.log() call.
Code to Reproduce
import type { Plugin } from "@opencode-ai/plugin"
export const TestPlugin: Plugin = async ({ client, directory }) => {
// This call causes hang
await client.app.log({
service: "test-plugin",
level: "info",
message: "Plugin initialized"
})
return {}
}
Root Cause Analysis
The issue appears to be infinite recursion in the logging system during plugin initialization:
- Plugin loads → calls
client.app.log()
- Logging system not fully initialized → triggers internal events
- Plugin system intercepts these events → tries to process them
- Plugin initialization continues → tries to log again
- Creates circular dependency → infinite loop/hang
Evidence
- Plugin appears in logs as "loading plugin"
- No subsequent log entries appear
- Process hangs at first logging call
- Complex
extra objects may exacerbate serialization issues
- Deferring logging with
setTimeout() resolves the issue
Workarounds
- Delay logging: Use
setTimeout(() => { /* log calls */ }, 500)
- Wrap in try-catch: Add error handling around all log calls
- Console logging: Use
console.log() for initialization debugging
Impact
- High: Prevents plugins from using the logging API properly
- Blocks development of robust plugins
- Forces plugin developers to use workarounds
Potential Fixes
The logging system should either:
- Queue logs during initialization: Buffer log calls until the system is ready
- Block event processing: Prevent plugin system from processing logs during initialization
- Add initialization lifecycle: Provide
onPluginReady or similar hook
- Fix recursion detection: Detect and prevent infinite logging loops
Additional Observations
- Issue occurs even with simple logging (minimal payload)
- Problem is specific to plugin initialization phase
- Regular logging after initialization works fine
- Multiple users reporting similar issues (community feedback)
Reacted by Ian Pascoe, Tyler Marshall and Antonio H L Santos
Activity
github-actions commented on Jan 11, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
ian-pascoe commented on Jan 20, 2026
Tigatok commented on Jan 30, 2026
+1, the official docs have this as an example
Metadata
Metadata
bugSomething isn't working Development
No branches or pull requestsIssue actions