connection.md: recovery for hung attached session - #541
Open
zachary-ai wants to merge 2 commits into
Open
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ring evaluate) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
✅ Skill review passedReviewed 1 file(s) — no findings. |
Contributor
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="helpers.py">
<violation number="1" location="helpers.py:152">
P2: Closing the current tab leaves `self.session` (in the daemon) pointing to a dead session. `ensure_real_tab()` may not always switch to a new tab — `current_tab()` can return the closed tab's URL (which doesn't start with INTERNAL), so the early-return path in `ensure_real_tab()` fires without calling `switch_tab()`. The daemon's stale-session auto-recovery on the next CDP call covers this, but there's a window where the next session-scoped call either fails or incurs a re-attach delay.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| # targetId — the attached session's id is not closable directly. | ||
| tid = target_id or current_tab()["targetId"] | ||
| cdp("Target.closeTarget", targetId=tid) | ||
| ensure_real_tab() |
Contributor
There was a problem hiding this comment.
P2: Closing the current tab leaves self.session (in the daemon) pointing to a dead session. ensure_real_tab() may not always switch to a new tab — current_tab() can return the closed tab's URL (which doesn't start with INTERNAL), so the early-return path in ensure_real_tab() fires without calling switch_tab(). The daemon's stale-session auto-recovery on the next CDP call covers this, but there's a window where the next session-scoped call either fails or incurs a re-attach delay.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At helpers.py, line 152:
<comment>Closing the current tab leaves `self.session` (in the daemon) pointing to a dead session. `ensure_real_tab()` may not always switch to a new tab — `current_tab()` can return the closed tab's URL (which doesn't start with INTERNAL), so the early-return path in `ensure_real_tab()` fires without calling `switch_tab()`. The daemon's stale-session auto-recovery on the next CDP call covers this, but there's a window where the next session-scoped call either fails or incurs a re-attach delay.</comment>
<file context>
@@ -143,6 +143,14 @@ def new_tab(url="about:blank"):
+ # targetId — the attached session's id is not closable directly.
+ tid = target_id or current_tab()["targetId"]
+ cdp("Target.closeTarget", targetId=tid)
+ ensure_real_tab()
+
def ensure_real_tab():
</file context>
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.
Adds a field-tested gotcha to interaction-skills/connection.md: when the daemon's attached tab has a hung renderer, every helper call (
page_info(),js()) blocks forever with no error while the daemon log looks healthy. Documents how to diagnose via browser-level CDP over the raw socket and re-point the default session at a fresh tab, plus the trap thatrestart_daemon()only stops the daemon.Hit in production on 20 Jul 2026 when a long-idle Mighty Networks feed tab stopped answering
Runtime.evaluateand hung a scheduled scan for 10+ minutes.🤖 Generated with Claude Code
Summary by cubic
Documents recovery for a hung attached CDP session and adds a
close_tab()helper so agents can clean up tabs and avoid indefinite blocking. This prevents stuckpage_info()/js()calls and provides a safe path to reattach to a fresh tab.close_tab(target_id=None)to close a page target and runensure_real_tab().interaction-skills/connection.mdwith steps to diagnose a hung session via raw CDP, create/attach a fresh target, set the default session, and caveats aboutswitch_tab()blocking andrestart_daemon()only stopping the daemon.Written for commit 75e1458. Summary will update on new commits.