Implementation:Puppeteer Puppeteer Browsers Launch
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Browser_Management, Process_Management |
| Last Updated | 2026-02-11 23:00 GMT |
Overview
Concrete tool for spawning and managing browser processes, provided by the @puppeteer/browsers package.
Description
The launch() function spawns a browser process and returns a Process object for lifecycle management. The Process class wraps Node.js child_process.ChildProcess with convenience methods for WebSocket endpoint detection, graceful shutdown, and signal handling.
Usage
Call this function with an executable path and arguments to spawn a browser process.
Code Reference
Source Location
- Repository: puppeteer
- launch function: packages/browsers/src/launch.ts (lines 205-207)
- Process class: packages/browsers/src/launch.ts (lines 277-653)
- LaunchOptions: packages/browsers/src/launch.ts (lines 135-198)
Signature
function launch(opts: LaunchOptions): Process;
class Process {
get nodeProcess(): child_process.ChildProcess;
close(): Promise<void>;
kill(): void;
waitForLineOutput(regex: RegExp, timeout?: number): Promise<string>;
}
Import
import {launch} from '@puppeteer/browsers';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| opts.executablePath | string | Yes | Path to browser binary |
| opts.args | string[] | No | CLI arguments for the browser |
| opts.pipe | boolean | No | Use pipe transport instead of WebSocket |
| opts.dumpio | boolean | No | Pipe browser stdout/stderr to Node.js process |
| opts.env | Record<string, string> | No | Environment variables for the browser process |
| opts.handleSIGINT | boolean | No | Forward SIGINT to browser (default: true) |
| opts.handleSIGTERM | boolean | No | Forward SIGTERM to browser (default: true) |
| opts.handleSIGHUP | boolean | No | Forward SIGHUP to browser (default: true) |
| opts.detached | boolean | No | Detach browser process from parent |
Outputs
| Name | Type | Description |
|---|---|---|
| return | Process | Process wrapper with close(), kill(), waitForLineOutput() methods |
Usage Examples
import {launch, install, Browser, detectBrowserPlatform, resolveBuildId} from '@puppeteer/browsers';
// First install the browser
const platform = detectBrowserPlatform();
const buildId = await resolveBuildId(Browser.CHROME, platform, 'stable');
const installed = await install({
cacheDir: '/tmp/browsers',
browser: Browser.CHROME,
buildId,
});
// Then launch it
const process = launch({
executablePath: installed.executablePath,
args: ['--remote-debugging-port=9222'],
});
// Wait for WebSocket endpoint
const wsEndpoint = await process.waitForLineOutput(
/DevTools listening on (ws:\/\/.*)$/,
30000
);
console.log(`Browser listening at: ${wsEndpoint}`);
// Cleanup
await process.close();
Related Pages
Implements Principle
Requires Environment
Uses Heuristic
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment