MCPcopy
hub / github.com/browserbase/mcp-server-browserbase / closeAllSessions

Method closeAllSessions

src/sessionManager.ts:447–470  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

445
446 // Function to close all managed browser sessions gracefully
447 async closeAllSessions(): Promise<void> {
448 process.stderr.write(`[SessionManager] Closing all sessions...\n`);
449 const closePromises: Promise<void>[] = [];
450 for (const [id, session] of this.browsers.entries()) {
451 process.stderr.write(`[SessionManager] Closing session: ${id}\n`);
452 closePromises.push(
453 // Use the helper for consistent logging/error handling
454 this.closeBrowserGracefully(session, id),
455 );
456 }
457 try {
458 await Promise.all(closePromises);
459 } catch {
460 // Individual errors are caught and logged by closeBrowserGracefully
461 process.stderr.write(
462 `[SessionManager] WARN - Some errors occurred during batch session closing. See individual messages.\n`,
463 );
464 }
465
466 this.browsers.clear();
467 this.defaultBrowserSession = null;
468 this.setActiveSessionId(this.defaultSessionId); // Reset active session to default
469 process.stderr.write(`[SessionManager] All sessions closed and cleared.\n`);
470 }
471}

Callers

nothing calls this directly

Calls 2

setActiveSessionIdMethod · 0.95

Tested by

no test coverage detected