| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
The following comment was made by an LLM, it may be inaccurate: SummaryNo duplicate PRs found. All searches returned only PR #7032 (the current PR), with one additional unrelated result about Intent abstraction (PR #6549). The searches covered:
This appears to be a unique PR addressing subscription memory leaks through new dispose functionality. |
Sorry, something went wrong.
There was a problem hiding this comment.
This PR adds dispose() functions to multiple namespaces to prevent Bus subscription memory leaks that were causing Bun to run out of memory during extended use. The implementation adds cleanup mechanisms for Share, ShareNext, Plugin, and Format modules, along with AbortController-based session cleanup for the ACP Agent.
Key Changes:
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file| File | Description |
|---|---|
| packages/opencode/src/bus/index.ts | Added internal test helper functions to query subscription counts |
| packages/opencode/src/share/share.ts | Added subscriptions array and dispose() function to clean up Bus subscriptions and pending queue |
| packages/opencode/src/share/share-next.ts | Added subscriptions array and dispose() function to clean up Bus subscriptions and queued timeouts |
| packages/opencode/src/plugin/index.ts | Added subscriptions array and dispose() function to clean up wildcard event subscriptions |
| packages/opencode/src/format/index.ts | Added subscriptions array and dispose() function to clean up File.Event.Edited subscriptions |
| packages/opencode/src/acp/agent.ts | Added sessionAbortControllers map, cleanupSession() and dispose() methods to manage session-scoped event subscriptions using AbortControllers |
| packages/opencode/test/memory/subscription-cleanup.test.ts | Added comprehensive unit tests verifying dispose functions work correctly for all modules |
| packages/opencode/test/memory/profile.ts | Added memory profiling script to validate no memory leaks occur during init/dispose cycles |
| packages/opencode/test/memory/acp-cleanup.test.ts | Added tests for ACP Agent session cleanup and AbortController management |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
|
All Copilot review feedback has been addressed:
|
Sorry, something went wrong.
There was a problem hiding this comment.
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was a problem hiding this comment.
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was a problem hiding this comment.
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was a problem hiding this comment.
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was a problem hiding this comment.
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
- Have Instance.state dispose callbacks delegate to exported dispose() functions to avoid duplication - Reorder init() to call dispose() before getting state reference for clearer semantics - Add afterAll cleanup in subscription-cleanup.test.ts to clean up temp directory - Wrap profile.ts test functions in Instance.provide for proper Instance context - Add closed property to ACP mock in profile.ts
- Perform Instance.state dispose cleanup inline to prevent state() reinitialization during Instance disposal - Add AbortController to cancel in-flight fetch requests during dispose - Pass abort signal to SDK event.subscribe to properly cancel SSE stream - Update comments to accurately reflect full dispose behavior - Add proper async generator cleanup in test
…and adding abort checks
|
This PR has been superseded by #7914, which is a clean re-implementation on current dev (this PR had merge conflicts that were complex to resolve). The new PR includes the same functionality:
Leaving this PR open per request, but #7914 should be reviewed instead. |
Sorry, something went wrong.
- Add dispose() to Share, ShareNext, Plugin, and Format namespaces - Add cleanupSession() and dispose() to ACP Agent with AbortControllers - Add Bus._getSubscriptionCount() test helpers - Add memory tests to verify cleanup works correctly Supersedes anomalyco#7032 Fixes anomalyco#3013
|
Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes #3013
Summary
Problem
Bus subscriptions were accumulating during extended use because the return values from Bus.subscribe() were being ignored. Over time, this caused memory growth that could contribute to Bun running out of memory.
Solution
Each module that subscribes to Bus events now:
For ACP Agent specifically, session-scoped subscriptions use AbortControllers so they can be cleaned up when a session ends.
Testing
Added 10 unit tests in test/memory/ that verify:
All tests pass: bun test test/memory/