-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Open
Labels
perfIndicates a performance issue or need for optimizationIndicates a performance issue or need for optimization
Description
Problem
When Instance.dispose() is called, several resources are not properly cleaned up:
1. Plugins Not Disposed
Plugins may hold resources (connections, file handles, caches) that need cleanup, but there's no disposal hook in the Hooks interface:
interface Hooks {
// No dispose() method exists
}2. Cached Instances Not Disposed
The instance cache uses a standard Map without disposal hooks. When instances are evicted (due to memory pressure or explicit removal), their state is not properly cleaned up.
3. No Bootstrap Cleanup
When the process exits, plugins are not given a chance to clean up their resources.
Code Locations
packages/plugin/src/index.ts- Hooks interfacepackages/opencode/src/plugin/index.ts- Plugin loadingpackages/opencode/src/project/instance.ts- Instance cachepackages/opencode/src/project/bootstrap.ts- Bootstrap process
Impact
- Plugin resources leak on instance disposal
- Cache eviction doesn't trigger cleanup
- Process exit leaves orphaned resources
Relates to #5363
Depends on #9140 (LRU cache utility needed for onEvict callback)
Expected Behavior
- Plugins should have a
dispose()hook - Cache eviction should trigger disposal
- Bootstrap should clean up plugins on exit
Metadata
Metadata
Assignees
Labels
perfIndicates a performance issue or need for optimizationIndicates a performance issue or need for optimization