MCPcopy
hub / github.com/firecrawl/firecrawl / browserExecuteController

Function browserExecuteController

apps/api/src/controllers/v2/browser.ts:394–495  ·  view source on GitHub ↗
(
  req: RequestWithAuth<
    { sessionId: string },
    BrowserExecuteResponse,
    BrowserExecuteRequest
  >,
  res: Response<BrowserExecuteResponse>,
)

Source from the content-addressed store, hash-verified

392}
393
394export async function browserExecuteController(
395 req: RequestWithAuth<
396 { sessionId: string },
397 BrowserExecuteResponse,
398 BrowserExecuteRequest
399 >,
400 res: Response<BrowserExecuteResponse>,
401) {
402 // if (!req.acuc?.flags?.browserBeta) {
403 // return res.status(403).json({
404 // success: false,
405 // error:
406 // "Browser is currently in beta. Please contact support@firecrawl.com to request access.",
407 // });
408 // }
409
410 req.body = browserExecuteRequestSchema.parse(req.body);
411
412 const id = req.params.sessionId;
413 const { code, language, timeout, origin } = req.body;
414
415 const logger = _logger.child({
416 sessionId: id,
417 teamId: req.auth.team_id,
418 module: "api/v2",
419 method: "browserExecuteController",
420 });
421
422 // Look up session from Supabase
423 const session = await getBrowserSession(id);
424
425 if (!session) {
426 return res.status(404).json({
427 success: false,
428 error: "Browser session not found.",
429 });
430 }
431
432 if (session.team_id !== req.auth.team_id) {
433 return res.status(403).json({
434 success: false,
435 error: "Forbidden.",
436 });
437 }
438
439 if (session.status === "destroyed") {
440 return res.status(410).json({
441 success: false,
442 error: "Browser session has been destroyed.",
443 });
444 }
445
446 // Update activity timestamp (fire-and-forget)
447 updateBrowserSessionActivity(id).catch(() => {});
448
449 logger.info("Executing code in browser session", { language, timeout });
450
451 // Execute code via the browser service

Callers

nothing calls this directly

Calls 6

getBrowserSessionFunction · 0.90
childMethod · 0.80
parseMethod · 0.45
jsonMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…