Skip to content

fix(lens): prevent crashes when closing tabs - #290

Merged
heath-s merged 1 commit into
mainfrom
fix/lens-kill
Jul 31, 2026
Merged

fix(lens): prevent crashes when closing tabs#290
heath-s merged 1 commit into
mainfrom
fix/lens-kill

Conversation

@heath-s

@heath-s heath-s commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • detach the native Lens view before teardown and retain its wrapper until WebContents destruction completes
  • tombstone closing sessions, reject stale event/CDP work, and force-detach stalled diagnostics
  • bound guest console payloads and event rates, automatically stopping full diagnostics under sustained overload
  • synchronize automatic diagnostics shutdown with the renderer without allowing stale async responses to re-enable the UI

Root cause

Local macOS crash reports showed both a WebContents lifecycle weak-callback failure during tab teardown and an out-of-memory path while handling page console messages. Closing a Lens tab could leave the native surface visible while stale listeners or CDP work continued, and high-volume console events were cloned and re-logged without byte or rate bounds.

Impact

Closing Lens tabs now removes the native surface immediately, prevents late session traffic from reaching replacement tabs, and keeps console/CDP overload from taking down Stave.

Verification

  • bun run test:ci
  • Lens regression suite: 190 tests passed
  • independent High/Medium review completed with no remaining findings

@heath-s
heath-s marked this pull request as ready for review July 31, 2026 11:08
@heath-s
heath-s enabled auto-merge (squash) July 31, 2026 11:08
@heath-s
heath-s requested a review from astyfx July 31, 2026 11:08

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15cf153ddd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

) {
return;
}
if (ownerSession.authPopups.size >= MAX_LENS_AUTH_POPUPS) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply the popup cap only to URLs that create popups

When three HTTP(S) auth windows are already open, this early limit check also rejects mailto:, custom-protocol, and other external links, even though the branch below would send those URLs to openExternalWithFallback without creating another popup. Move the non-HTTP(S) handling before the auth-popup count check so ordinary external links continue working at the popup limit.

Useful? React with 👍 / 👎.

@heath-s
heath-s merged commit 2f945c2 into main Jul 31, 2026
4 checks passed
@heath-s
heath-s deleted the fix/lens-kill branch July 31, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants