fix(cua): make session.stop() idempotent on repeated call#156
Merged
masnwilliams merged 1 commit intohypeship/unified-cua-templatefrom May 5, 2026
Merged
Conversation
After PR #155 reset session state inside the finally, a follow-up stop() from the caller's error path reliably hit the throwing 'sessionId' getter via 'this.info' / 'self.info' (info accesses sessionId, which raises 'Session not started' when _sessionId is null). The exception masked the original error. stop() now short-circuits with a snapshot of the cleared state when no session is active, and builds the live-session info from local fields without going through the throwing getter. Applied symmetrically in TS and Python. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Firetiger deploy monitoring skipped This PR didn't match the auto-monitor filter configured on your GitHub connection:
Reason: PR modifies session handling logic (CUA template) with no changes to kernel API endpoints or Temporal workflows, which are the specific monitored paths in packages/api/cmd/api/ and packages/api/lib/temporal. To monitor this PR anyway, reply with |
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.
Summary
Stacks on top of the unified CUA template branch. Addresses the new High-Severity Cursor Bugbot finding on PR #143's latest scan:
stop()throws on repeated call instead of being a no-op.Background
PR #155 moved the session-state reset (
_sessionId = null, …) into thefinallyso that a thrown replay-stop or browser-delete error wouldn't leave stale state behind. That fix was correct, but it exposed a latent bug:stop()opens withconst info = this.info(TS) /info = self.info(Py), and theinfogetter delegates to thesessionIdproperty, which raises when_sessionIdis null. So once PR #155 reliably cleared_sessionIdon the first call, the caller's error-path retry would hit the throwing getter and mask the original exception — exactly the failure mode PR #155 was meant to prevent.Fix
stop()now:SessionInfowhen no session is active — never touches the throwing getter.infofrom local fields directly so the body never depends onthis.info/self.infoeither.Symmetric in TS (
session.ts) and Python (session.py).Test plan
go build ./...go test ./pkg/create/...session.stop()twice from the caller's error path no longer raises and the original error surfaces.Note
Medium Risk
Touches session shutdown/cleanup logic in both Python and TypeScript templates; while small, mistakes could lead to leaked browser sessions or masked errors during teardown.
Overview
KernelBrowserSession.stop()in bothpkg/templates/python/cua/session.pyandpkg/templates/typescript/cua/session.tsis updated to be idempotent.It now short-circuits when no active session exists (returning a sentinel
SessionInfowithout readinginfo/sessionId), and builds the returnedSessionInfodirectly from internal fields so teardown can’t fail due to accessing a getter after state has been cleared.Reviewed by Cursor Bugbot for commit db0bdea. Bugbot is set up for automated code reviews on this repo. Configure here.