fix: memory leaks, error handling, and retry logic improvements#11717
Closed
riftzen-bit wants to merge 2 commits intoanomalyco:devfrom
Closed
fix: memory leaks, error handling, and retry logic improvements#11717riftzen-bit wants to merge 2 commits intoanomalyco:devfrom
riftzen-bit wants to merge 2 commits intoanomalyco:devfrom
Conversation
## Bug Fixes ### Timer Memory Leak in withTimeout (HIGH) - Fixed: Timer not cleared when promise rejects - Changed `.then()` to `.finally()` to ensure cleanup in all code paths - Location: src/util/timeout.ts ### Event Listener Memory Leak in OAuth Flow (HIGH) - Fixed: Event listeners not removed after one fires - Changed `.on()` to `.once()` for subprocess error/exit handlers - Location: src/mcp/index.ts ### Silent Cache Clearing Failure (MEDIUM) - Fixed: Version file written even when cache deletion fails - Moved version write inside try block, added error logging - Location: src/global/index.ts ### Inconsistent Retry Logic Return Value (LOW) - Fixed: retryable() returned raw JSON.stringify for unrecognized errors - Now returns undefined for non-retryable errors (consistent behavior) - Location: src/session/retry.ts - Updated test to match new correct behavior Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
|
@riftzen-bit does this fix work for you? This is what my machine looks like |
Contributor
Author
|
This solution worked perfectly for me. |
This was referenced Feb 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
This PR addresses several memory leaks and error handling issues discovered during a deep code review:
Bug Fixes
HIGH Priority:
Timer Memory Leak in
withTimeout(src/util/timeout.ts).then()to.finally()to ensure cleanup in all code pathsEvent Listener Memory Leak in OAuth Flow (
src/mcp/index.ts)error,exit) were not removed after one fired.on()to.once()for subprocess handlersMEDIUM Priority:
src/global/index.ts)LOW Priority:
src/session/retry.ts)retryable()returned rawJSON.stringify()for unrecognized errorsundefinedfor non-retryable errors (consistent behavior)Files Changed
packages/opencode/src/util/timeout.ts- Timer cleanup fixpackages/opencode/src/mcp/index.ts- Event listener fixpackages/opencode/src/global/index.ts- Cache error handlingpackages/opencode/src/session/retry.ts- Retry logic fixpackages/opencode/test/session/retry.test.ts- Updated testTesting
Checklist