-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Recover bounded capture deadlines and preserve terminal session loss #2893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
miguelg719
wants to merge
13
commits into
evals/consolidation-02-session-ownership
from
evals/consolidation-03-capture-recovery
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5c9e720
Recover bounded capture deadlines and preserve terminal session loss
miguelg719 41af704
style(core): format capture regression imports
miguelg719 e043e1e
fix(runtime): preserve terminal diagnostics and public error boundaries
miguelg719 8e887b3
Merge branch 'evals/consolidation-02-session-ownership' into evals/co…
miguelg719 e8e9d6b
Merge branch 'evals/consolidation-02-session-ownership' into evals/co…
miguelg719 f915e6b
Merge branch 'evals/consolidation-02-session-ownership' into evals/co…
miguelg719 90721ea
fix(evals): defer runtime loading for general CLI help
miguelg719 e16f1bc
Merge branch 'evals/consolidation-02-session-ownership' into evals/co…
miguelg719 5addea3
Merge commit 'ef260fa71343690b316a136ca7575a2c26af8501' into HEAD
miguelg719 cc584ef
Merge commit '26a8845bc1f5659022f8cbc1008ac0eff0eede20' into HEAD
miguelg719 5671f3c
Refresh CI after syncing the reviewed parent
miguelg719 b63a080
Merge commit '6c1c5d92c73eea89a48f05f45efc994f683f8ddb' into HEAD
miguelg719 749da11
Merge commit '0679a58b1ffc1d6f17165c28d4c31642fd06ea50' into HEAD
miguelg719 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@browserbasehq/stagehand": patch | ||
| --- | ||
|
|
||
| Bound experimental batch and RPC deadlines so callers can stop waiting without replaying actions or accepting late capture state. |
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
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
70 changes: 70 additions & 0 deletions
70
packages/evals/tests/core/browserSessionLossTelemetry.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { | ||
| parseSessionLossTelemetry, | ||
| SESSION_LOST_TELEMETRY_PREFIX, | ||
| } from "../../core/tools/browserSessionLoss.js"; | ||
|
|
||
| function line(fields: Record<string, unknown>) { | ||
| return ( | ||
| SESSION_LOST_TELEMETRY_PREFIX + JSON.stringify({ cause: "CDP connection closed", ...fields }) | ||
| ); | ||
| } | ||
|
|
||
| describe("facade session loss diagnostics", () => { | ||
| it("retains browser identity, measured age and configured timeout", () => { | ||
| expect( | ||
| parseSessionLossTelemetry( | ||
| line({ | ||
| tool: "snapshot", | ||
| at: "2026-09-08T00:00:00.000Z", | ||
| provider: "browserbase", | ||
| sessionId: "session-123", | ||
| sessionAgeMs: 12_500, | ||
| sessionTimeoutMs: 3_600_000, | ||
| }), | ||
| ), | ||
| ).toEqual({ | ||
| cause: "CDP connection closed", | ||
| tool: "snapshot", | ||
| at: "2026-09-08T00:00:00.000Z", | ||
| provider: "browserbase", | ||
| sessionId: "session-123", | ||
| sessionAgeMs: 12_500, | ||
| sessionTimeoutMs: 3_600_000, | ||
| }); | ||
| }); | ||
|
|
||
| it.each([-1, "12000", null, {}, 1e309])("drops invalid diagnostic durations: %j", (value) => { | ||
| expect( | ||
| parseSessionLossTelemetry(line({ sessionAgeMs: value, sessionTimeoutMs: value })), | ||
| ).toEqual({ cause: "CDP connection closed" }); | ||
| }); | ||
|
|
||
| it("accepts zero age and omits invalid identity metadata", () => { | ||
| expect( | ||
| parseSessionLossTelemetry(line({ provider: "other", sessionId: 42, sessionAgeMs: 0 })), | ||
| ).toEqual({ cause: "CDP connection closed", sessionAgeMs: 0 }); | ||
| }); | ||
|
|
||
| it("drops JSON numeric overflow without losing the terminal cause", () => { | ||
| expect( | ||
| parseSessionLossTelemetry( | ||
| SESSION_LOST_TELEMETRY_PREFIX + | ||
| '{"cause":"CDP connection closed","sessionAgeMs":1e309,"sessionTimeoutMs":1e309}', | ||
| ), | ||
| ).toEqual({ cause: "CDP connection closed" }); | ||
| }); | ||
|
|
||
| it("sanitizes string diagnostics while retaining valid numeric metadata", () => { | ||
| const parsed = parseSessionLossTelemetry( | ||
| line({ | ||
| provider: "local", | ||
| sessionId: "wss://example.test/?apiKey=synthetic-key", | ||
| sessionAgeMs: 1, | ||
| }), | ||
| ); | ||
| expect(parsed?.provider).toBe("local"); | ||
| expect(parsed?.sessionAgeMs).toBe(1); | ||
| expect(JSON.stringify(parsed)).not.toContain("synthetic-key"); | ||
| }); | ||
| }); |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.