GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: clean up pending permissions when session is deleted by hendem · Pull Request #7154 · anomalyco/opencode

Conversation

@hendem

@hendem hendem commented Jan 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot AI review requested due to automatic review settings January 7, 2026 02:09
Copilot started reviewing on behalf of hendem January 7, 2026 02:10
View session
@github-actions

github-actions Bot commented Jan 7, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot AI reviewed Jan 7, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/opencode/test/permission/cleanup.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/test/permission/cleanup.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/src/permission/next.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/src/permission/next.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/test/permission/cleanup.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hendem
hendem requested a review from Copilot January 7, 2026 03:54
Copilot started reviewing on behalf of hendem January 7, 2026 03:54
View session
Copilot AI reviewed Jan 7, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/opencode/test/permission/cleanup.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/src/permission/next.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/test/permission/cleanup.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/test/permission/cleanup.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread packages/opencode/test/permission/cleanup.test.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hendem
hendem requested a review from Copilot January 7, 2026 04:41
Copilot started reviewing on behalf of hendem January 7, 2026 04:41
View session
Copilot AI reviewed Jan 7, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hendem
hendem requested a review from Copilot January 7, 2026 04:44
Copilot started reviewing on behalf of hendem January 7, 2026 04:45
View session
Copilot AI reviewed Jan 7, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/opencode/src/permission/next.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hendem
hendem requested a review from Copilot January 7, 2026 04:51
Copilot started reviewing on behalf of hendem January 7, 2026 04:51
View session
Copilot AI reviewed Jan 7, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/opencode/src/permission/next.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@hendem
hendem requested a review from Copilot January 7, 2026 05:00
Copilot started reviewing on behalf of hendem January 7, 2026 05:00
View session
Copilot AI reviewed Jan 7, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added the needs:issue label Jan 9, 2026
@github-actions

github-actions Bot commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs:issue label Jan 9, 2026
@hendem hendem mentioned this pull request Jan 9, 2026
fix: force kill MCP server processes on dispose to prevent orphan processes #7424
Closed
@github-actions github-actions Bot added needs:issue and removed needs:issue labels Jan 9, 2026
@fwang
fwang force-pushed the dev branch from 4da2998 to a618fbe Compare January 9, 2026 06:32
@fwang
fwang requested a review from adamdotdevin as a code owner January 9, 2026 06:32
Mark Henderson added 3 commits January 10, 2026 14:09
Mark Henderson @fwang
fix: clean up pending permissions when session is deleted
50c3de7
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.
Mark Henderson @fwang
address PR review comments
e8ae922
- 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)
Mark Henderson @fwang
fix: use Session.Event.Deleted instead of manually constructed event
700188f
Address Copilot review comments - import Session and use the proper
Session.Event.Deleted event definition instead of bypassing type
checking with manually constructed objects.
Mark Henderson and others added 3 commits January 10, 2026 14:09
Mark Henderson @fwang
fix: reorder operations in clearSession and reply to prevent race con…
1ca0826
…dition
@fwang
Revert "wip: zen"
0cc9f14
This reverts commit 7b9bc5370b08ec55c543de381b88eaf9c050a139.

wip: zen

Reapply "wip: zen"

This reverts commit 09516ac8c3bb7c432b28cf63faa65c0e3b9f9684.
Mark Henderson @fwang
fix: consistent ordering in reply function for once/always cases
a9f2024
@fwang
fwang force-pushed the fix/permission-approved-map-leak branch from 9f56615 to a9f2024 Compare January 10, 2026 19:11
@hendem
Merge branch 'dev' into fix/permission-approved-map-leak
5bad3ad
@github-actions github-actions Bot mentioned this pull request Jan 13, 2026
fix(state): delete key from recordsByKey on instance disposal #8252
Merged
@github-actions github-actions Bot mentioned this pull request Jan 24, 2026
fix(opencode): memory leaks in session handling #10392
Closed
@thdxr
thdxr force-pushed the dev branch from cbab81f to 2d3c7a0 Compare January 30, 2026 04:50
@opencode-agent
opencode-agent Bot force-pushed the dev branch from 00637c0 to 71e0ba2 Compare January 30, 2026 14:32
@thdxr
thdxr force-pushed the dev branch 3 times, most recently from f1ae801 to 08fa7f7 Compare January 30, 2026 14:37
@github-actions github-actions Bot mentioned this pull request Feb 28, 2026
fix: consolidate memory leak fixes from #14650 and #8953 #15435
Closed
3 of 6 tasks
@github-actions

github-actions Bot commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@adamdotdevin adamdotdevin Awaiting requested review from adamdotdevin

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uses a huge amount of memory

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@hendem @fwang
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.