File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -78,14 +78,11 @@ async function getBrowser(
78
78
) : Promise < BrowserResult > {
79
79
if ( env === "BROWSERBASE" ) {
80
80
if ( ! apiKey ) {
81
- logger ( {
82
- category : "init" ,
83
- message :
84
- "BROWSERBASE_API_KEY is required to use BROWSERBASE env. Defaulting to LOCAL." ,
85
- level : 0 ,
86
- } ) ;
87
- env = "LOCAL" ;
81
+ throw new Error (
82
+ 'BROWSERBASE_API_KEY is required to use the BROWSERBASE environment. Please set it in your .env or pass it in.'
83
+ ) ;
88
84
}
85
+
89
86
if ( ! projectId ) {
90
87
logger ( {
91
88
category : "init" ,
@@ -536,6 +533,14 @@ export class Stagehand {
536
533
this . intEnv = env ;
537
534
this . apiKey = apiKey ?? process . env . BROWSERBASE_API_KEY ;
538
535
this . projectId = projectId ?? process . env . BROWSERBASE_PROJECT_ID ;
536
+
537
+ if ( this . intEnv === "BROWSERBASE" && ! this . apiKey ) {
538
+ throw new Error (
539
+ 'Stagehand is set to use "BROWSERBASE" but no BROWSERBASE_API_KEY was found. Please set it in your .env or pass it explicitly.'
540
+ ) ;
541
+ }
542
+
543
+
539
544
this . verbose = verbose ?? 0 ;
540
545
// Update logger verbosity level
541
546
this . stagehandLogger . setVerbosity ( this . verbose ) ;
You can’t perform that action at this time.
0 commit comments