Fix tab leak: add closure timeout and reaper recovery for stuck tabs - #39
Open
hamsterkacke wants to merge 1 commit into
Open
Conversation
Tab closures could hang indefinitely when CDP WebSocket calls stall (dead connection, Chrome overloaded), leaving tabs permanently stuck with closing=true. The reaper sweep unconditionally skipped these tabs, so they were never cleaned up. Three fixes: - Wrap perform_tab_closure with a 15s timeout so hangs trigger the existing retry logic instead of blocking forever - Track closing_since timestamp; reaper resets stuck closures after 30s so they become eligible for force-close on the next sweep - Only nullify browser/tab references on successful closure so retries can still use the primary close path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Tabs can become permanently leaked when CDP WebSocket calls hang during closure (dead connection, Chrome overloaded, etc.). When this happens:
perform_tab_closureblocks indefinitely on a CDP call with no timeouttab_info.closingstaystrueforever since the function never returnsclosing = true, so it can never clean them upThe tab stays open in Chrome permanently — both the normal close path and the reaper are defeated.
Fix
Three changes in
cdp.js, designed as defense-in-depth:perform_tab_closureis wrapped withPromise.raceso hangs trigger the existing retry logic instead of blocking foreverclosing_sinceand resets stuck closures so they become eligible for force-close on the next sweeptab_info.browser/tab_info.tabare only nullified on successful closure, preserving the primary close method for retries