-
Notifications
You must be signed in to change notification settings - Fork 5.3k
fix: clean up pending permissions when session is deleted #7154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds session cleanup functionality to the PermissionNext namespace to prevent memory leaks when sessions are deleted. It introduces init(), dispose(), and clearSession() methods that subscribe to session.deleted events and clean up orphaned pending permissions.
Key changes:
- Adds event subscription mechanism to automatically clean up pending permissions when sessions are deleted
- Introduces init() and dispose() functions to manage event subscriptions lifecycle
- Adds clearSession() to reject and remove pending permissions for a specific session
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| packages/opencode/src/permission/next.ts | Implements init(), dispose(), and clearSession() functions with session.deleted event subscription to clean up orphaned pending permissions |
| packages/opencode/test/permission/cleanup.test.ts | Adds comprehensive test coverage for the new cleanup functionality including session clearing, event subscription, disposal, and duplicate init handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
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. |
Add init(), dispose(), and clearSession() to PermissionNext namespace to properly clean up pending permission requests when a session is deleted. This prevents memory accumulation from orphaned pending entries that would never be resolved. The fix subscribes to the session.deleted bus event and rejects all pending permissions for that session, allowing proper garbage collection.
- Move subscriptions to per-instance state instead of module-level - Add Event.Replied publishing in clearSession for consistency - Make init() and dispose() async to work with instance state - Remove unnecessary setTimeout delays in tests (Bus.publish awaits handlers)
Address Copilot review comments - import Session and use the proper Session.Event.Deleted event definition instead of bypassing type checking with manually constructed objects.
This reverts commit 7b9bc5370b08ec55c543de381b88eaf9c050a139. wip: zen Reapply "wip: zen" This reverts commit 09516ac8c3bb7c432b28cf63faa65c0e3b9f9684.
9f56615 to
a9f2024
Compare
Fixes #3013
Summary
init(),dispose(), andclearSession()toPermissionNextnamespacesession.deletedbus event to clean up orphaned pending permissionsProblem
When a session is deleted, any pending permission requests for that session remain in the
pendingmap indefinitely. This causes:Solution
Subscribe to the
session.deletedevent and clean up all pending permissions for deleted sessions by:RejectedErrorpendingmapTesting
Added comprehensive tests in
test/permission/cleanup.test.ts.