-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Before submitting an issue, please:
- Check the documentation for relevant information
- Search existing issues to avoid duplicates
Environment Information
Stagehand:
- Language/SDK: TypeScript
- Stagehand version: 3.0.6
AI Provider:
- Provider: Browserbase
- Model: N/A (issue occurs during initialization)
Runtime Environment:
- Framework: Next.js 14+ (App Router / Pages Router)
- Node.js: 20.x
- Deployment: Vercel / Railway
Issue Description
When using @browserbasehq/stagehand in Next.js projects, all Stagehand operations fail with the following error:
Error: unable to determine transport target for "pino-pretty"
Root Cause
The pino-pretty dependency is currently declared as a regular dependency. In Next.js and serverless environments, pino-pretty relies on Node.js worker threads which may not be available or properly initialized at runtime, causing failures when pino attempts to load it as a transport target.
Affected Environments
- ✅ Next.js (App Router / Pages Router)
- ✅ Remix, SvelteKit, and other modern bundler-based frameworks
- ✅ Serverless environments (Vercel, Netlify, AWS Lambda)
- ❌ Pure Node.js environments (unaffected)
Steps to Reproduce
- Create a Next.js 14+ project
- Install
@browserbasehq/stagehand@3.0.6 - Initialize Stagehand in an API Route or Server Component
- Run or build the application
Minimal Reproduction Code
// app/api/test/route.ts (Next.js 14 App Router)
import { Stagehand } from "@browserbasehq/stagehand";
export async function GET() {
const stagehand = new Stagehand({
env: "BROWSERBASE",
apiKey: process.env.BROWSERBASE_API_KEY,
projectId: process.env.BROWSERBASE_PROJECT_ID,
verbose: 1,
});
try {
await stagehand.init(); // ❌ Fails here
const page = stagehand.context.pages()[0];
await page.goto("https://example.com");
return Response.json({ success: true });
} catch (error) {
console.error(error);
return Response.json({ error: String(error) }, { status: 500 });
}
}Error Messages / Log trace
Navigation failed: Error: unable to determine transport target for "pino-pretty"
at p1 (.next/server/chunks/[root-of-the-server]__9b8e2a0d._.js:5:324)
at Object.execute (.next/server/chunks/[root-of-the-server]__9b8e2a0d._.js:10:214)
Current Workaround
Users can bypass this issue by setting disablePino: true:
const stagehand = new Stagehand({
env: "BROWSERBASE",
apiKey: process.env.BROWSERBASE_API_KEY,
projectId: process.env.BROWSERBASE_PROJECT_ID,
verbose: 1,
disablePino: true, // ⭐ Workaround
});However, this requires manual configuration for each project.
Screenshots / Videos
N/A
Additional Context
I noticed that:
- The code already has fallback logic when pino-pretty is unavailable (
lib/logger.ts:49-52) - All test configurations use
disablePino: true pino-prettyis currently independencies, which causes bundlers to include it even in production builds- According to Pino's documentation, pino-pretty is designed for development environments only
I'm wondering if moving pino-pretty to optionalDependencies would help, but I'm concerned about the verbose parameter defaulting to 1 and pretty: true in the code. I'm not sure how this would affect the default behavior. Any guidance would be appreciated!