[PR #7154] fix: clean up pending permissions when session is deleted #12276

Open
opened 2026-02-16 18:17:12 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7154

State: open
Merged: No


Fixes #3013

Summary

  • Add init(), dispose(), and clearSession() to PermissionNext namespace
  • Subscribe to session.deleted bus event to clean up orphaned pending permissions
  • Reject all pending permission requests when their session is deleted

Problem

When a session is deleted, any pending permission requests for that session remain in the pending map indefinitely. This causes:

  • Memory accumulation over time as pending entries are never removed
  • Orphaned promises that never resolve or reject

Solution

Subscribe to the session.deleted event and clean up all pending permissions for deleted sessions by:

  1. Rejecting pending promises with RejectedError
  2. Removing entries from the pending map

Testing

Added comprehensive tests in test/permission/cleanup.test.ts.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7154 **State:** open **Merged:** No --- Fixes #3013 ## Summary - Add `init()`, `dispose()`, and `clearSession()` to `PermissionNext` namespace - Subscribe to `session.deleted` bus event to clean up orphaned pending permissions - Reject all pending permission requests when their session is deleted ## Problem When a session is deleted, any pending permission requests for that session remain in the `pending` map indefinitely. This causes: - Memory accumulation over time as pending entries are never removed - Orphaned promises that never resolve or reject ## Solution Subscribe to the `session.deleted` event and clean up all pending permissions for deleted sessions by: 1. Rejecting pending promises with `RejectedError` 2. Removing entries from the `pending` map ## Testing Added comprehensive tests in `test/permission/cleanup.test.ts`.
yindo added the pull-request label 2026-02-16 18:17:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12276