Skip to content

Commit c19ad7f

Browse files
miguelg719kamath
andauthored
handle reroute for rollout (#786)
* handle reroute for rollout * Update .changeset/rude-lions-call.md * addressing comments * fix undefined for null --------- Co-authored-by: Anirudh Kamath <github@kamath.io>
1 parent 94b23d7 commit c19ad7f

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

.changeset/rude-lions-call.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@browserbasehq/stagehand": patch
3+
---
4+
5+
Handle reroute to account for rollout

lib/api.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ export class StagehandAPI {
9292

9393
this.sessionId = sessionResponseBody.data.sessionId;
9494

95+
// Temporary reroute for rollout
96+
if (!sessionResponseBody.data?.available) {
97+
sessionResponseBody.data.sessionId = null;
98+
}
99+
95100
return sessionResponseBody.data;
96101
}
97102

lib/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,9 @@ export class Stagehand {
728728
browserbaseSessionCreateParams: this.browserbaseSessionCreateParams,
729729
browserbaseSessionID: this.browserbaseSessionID,
730730
});
731+
if (!sessionId) {
732+
this.apiClient = null;
733+
}
731734
this.browserbaseSessionID = sessionId;
732735
}
733736

types/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface StartSessionParams {
2929

3030
export interface StartSessionResult {
3131
sessionId: string;
32+
available?: boolean;
3233
}
3334

3435
export interface SuccessResponse<T> {

0 commit comments

Comments
 (0)