browserPool module manages Puppeteer browser pool for scraping, handling lifecycle and reuse.
import puppeteer, { Browser, Page } from 'puppeteer';
// Note: Using regular puppeteer for now to avoid stealth plugin compatibility issues
// Stealth features are implemented manually in browser configuration
console.log('๐ง Using regular Puppeteer with manual stealth configuration');
interface BrowserInstance {
id: string;
browser: Browser;
lastUsed: Date;
memoryUsage: number;
requestCount: number;
}
interface PageInstance {
page: Page;
browserId: string;
inUse: boolean;
}
class BrowserPool {
private browsers: Map<string, BrowserInstance> = new Map();
private pages: PageInstance[] = [];
// PUPPETEER_MAX_BROWSERS โ max concurrent browser instances (default: 5)
private maxBrowsers = parseInt(process.env.PUPPETEER_MAX_BROWSERS || '5', 10);
private browserIdleTim
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key