Skip to content

Unable to create browserbase session in nextjs backend #152

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 · 3 comments
Closed

Unable to create browserbase session in nextjs backend #152

KenjiPcx opened this issue Mar 21, 2025 · 3 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

Moved it to the cua repo browserbase/cua-browser#10

@majkiw
Copy link

majkiw commented Mar 27, 2025

Not sure why it was moved to browserbase/cua-browser#10

It is still a problem on NextJS 15.2.3.
Turning off turbopack (as suggested in that other issue), while a great workaround, isn't a real solution as turbopack is critical for bigger apps.

Any suggested workarounds?

@rattrayalex
Copy link

v2.5.0 of this library works around this issue. Please upgrade and give it a try.

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

3 participants