Implementation:Microsoft Playwright IPC Driver
| Knowledge Sources | |
|---|---|
| Domains | Inter-Process Communication, Server Infrastructure |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Concrete tool for running the Playwright server as an IPC subprocess that communicates via stdin/stdout pipe transport, provided by the Playwright library.
Description
This module provides the entry points for the Playwright driver process used by non-JavaScript language bindings (Python, .NET, Java). The runDriver() function creates a DispatcherConnection with a RootDispatcher and PlaywrightDispatcher, then connects them to a PipeTransport on process.stdout/process.stdin. It handles JSON serialization (including well-formed string support for non-JS bindings), graceful shutdown on transport close, and SIGINT suppression. The module also exports runServer() for starting a WebSocket-based PlaywrightServer, printApiJson() to dump the API schema, and launchBrowserServer() to launch a browser server from configuration.
Usage
Use these functions when launching the Playwright driver process from language binding CLIs or when starting a remote Playwright server. runDriver() is the primary entry point for the IPC driver subprocess used by non-JavaScript Playwright SDKs.
Code Reference
Source Location
- Repository: Microsoft_Playwright
- File:
packages/playwright-core/src/cli/driver.ts
Signature
export function printApiJson(): void;
export function runDriver(): void;
export type RunServerOptions = {
port?: number;
host?: string;
path?: string;
extension?: boolean;
maxConnections?: number;
browserProxyMode?: 'client' | 'tether';
ownedByTetherClient?: boolean;
};
export async function runServer(options: RunServerOptions): Promise<void>;
export async function launchBrowserServer(browserName: string, configFile?: string): Promise<void>;
Import
import { runDriver, runServer, printApiJson, launchBrowserServer } from 'playwright-core/src/cli/driver';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| options (runServer) | RunServerOptions |
No | Server configuration including port, host, path, extension mode, and max connections |
| browserName (launchBrowserServer) | string |
Yes | The browser engine name (chromium, firefox, webkit) |
| configFile (launchBrowserServer) | string |
No | Path to a JSON config file with LaunchServerOptions |
Outputs
| Name | Type | Description |
|---|---|---|
| (runDriver) | void |
Sets up pipe transport on stdin/stdout for IPC communication; runs until transport closes |
| (runServer) | void |
Starts WebSocket server and prints the endpoint URL to stdout |
| (printApiJson) | void |
Prints the API JSON schema to stdout |
| (launchBrowserServer) | void |
Launches a browser server and prints the wsEndpoint to stdout |
Usage Examples
// Typically invoked from CLI:
// npx playwright run-driver
runDriver();
// Start a WebSocket server:
await runServer({ port: 3000, path: '/ws' });
// Launch a browser server with config:
await launchBrowserServer('chromium', './browser-config.json');