-
Notifications
You must be signed in to change notification settings - Fork 24
Browser updates #6
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
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
c36be5a
to
a82f7ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Comments:
sdk/stagehand-ts/lib/index.ts (line 875):
The close()
method will throw an error if called before init()
or if init()
fails, because it tries to access this.context
which requires stagehandContext
to be initialized.
View Details
📝 Patch Details
diff --git a/sdk/stagehand-ts/dist/index.js b/sdk/stagehand-ts/dist/index.js
index ff6c1d6..e3da4b6 100644
--- a/sdk/stagehand-ts/dist/index.js
+++ b/sdk/stagehand-ts/dist/index.js
@@ -23726,7 +23726,9 @@ var Stagehand3 = class {
this.apiClient = null;
return;
} else {
- yield this.context.close();
+ if (this.stagehandContext) {
+ yield this.context.close();
+ }
if (this._browser) {
yield this._browser.close();
}
diff --git a/sdk/stagehand-ts/lib/index.ts b/sdk/stagehand-ts/lib/index.ts
index e158322..88c75ac 100644
--- a/sdk/stagehand-ts/lib/index.ts
+++ b/sdk/stagehand-ts/lib/index.ts
@@ -872,7 +872,9 @@ export class Stagehand {
this.apiClient = null;
return;
} else {
- await this.context.close();
+ if (this.stagehandContext) {
+ await this.context.close();
+ }
if (this._browser) {
await this._browser.close();
}
Analysis
close() method fails when called before init() due to unguarded context access
What fails: Stagehand.close()
throws StagehandNotInitializedError
when called before init()
because it unconditionally calls this.context.close()
which requires stagehandContext
to be initialized
How to reproduce:
const stagehand = new Stagehand({ env: "LOCAL" });
await stagehand.close(); // Throws StagehandNotInitializedError
Result: Throws "You seem to be calling context
on a page in an uninitialized Stagehand
object. Ensure you are running await stagehand.init()
on the Stagehand object before referencing the page
object."
Expected: close()
should handle uninitialized state gracefully, especially since signal handlers (SIGINT/SIGTERM) registered in constructor call close()
for cleanup - if process is interrupted before init()
completes, cleanup fails instead of gracefully handling uninitialized state.
Technical details: The context
getter at lines 735-739 in lib/index.ts
throws when this.stagehandContext
is undefined, but close()
method at line 875 calls await this.context.close()
without checking initialization state.
068e638
to
a079f57
Compare
* update urls, ts ignore fix (#8) * feat: add query param parsing (#9) * update urls, ts ignore fix * added query param parsing to instatiate chatfeed with query params * disable captcha solving if query params are passed in (#10) * update gemini model * update model tag (#12) * add region routing * more precise region & probability dist routing * no inline import * add dep --------- Co-authored-by: Kyle Jeong <77771518+Kylejeong2@users.noreply.github.com> Co-authored-by: Miguel <36487034+miguelg719@users.noreply.github.com>
This reverts commit 1ea7c9c.
No description provided.