Skip to content

Unable to create browserbase session in nextjs backend #10

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

Closed
KenjiPcx opened this issue Mar 21, 2025 · 2 comments
Closed

Unable to create browserbase session in nextjs backend #10

KenjiPcx opened this issue Mar 21, 2025 · 2 comments

Comments

@KenjiPcx
Copy link

When I try and request a browser base agent with a nextjs app
const session = await bb.sessions.create({
projectId: process.env.BROWSERBASE_PROJECT_ID!,
browserSettings,
keepAlive: true,
region: getClosestRegion(timezone),
timeout: 600,
});

I get this error

Error creating session: TypeError: (0 , __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f40$browserbasehq$2b$sdk$40$2$2e$4$2e$0$2f$node_modules$2f40$browserbasehq$2f$sdk$2f$_shims$2f$registry$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__.getDefaultAgent) is not a function
    at Browserbase.buildRequest (src/core.ts:297:77)
    at Browserbase.makeRequest (src/core.ts:430:39)
    at async createSession (app/(browserbase)/api/session/route.ts:95:18)
    at async POST (app/(browserbase)/api/session/route.ts:129:24)
  93 |     blockAds: true,
  94 |   };
> 95 |   const session = await bb.sessions.create({
     |                  ^
  96 |     projectId: process.env.BROWSERBASE_PROJECT_ID!,
  97 |     browserSettings,
  98 |     keepAlive: true,
 POST /api/session 500 in 764ms

It's complaining the getDefaultAgent is not a function for some reason

Any ideas how I can fix this?

@KenjiPcx
Copy link
Author

Found the issue, I had updated my nextjs to 15.2.2-canary.1
Turbopack was causing an issue indeed

@ayush-goyal
Copy link

Changing next dev --turbo to next dev worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants