fix(lens): prevent crashes when closing tabs - #290
Conversation
There was a problem hiding this comment.
💡 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) { |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
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