Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Playwright PipeTransport

From Leeroopedia
Revision as of 11:37, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Microsoft_Playwright_PipeTransport.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:Implementation Page

Overview

PipeTransport implements the ConnectionTransport interface over stdio pipes, enabling JSON-based protocol communication with browser processes via stdin/stdout.

Description

The PipeTransport class provides a newline-delimited JSON transport over Node.js readable/writable streams. It reads incoming data from the pipe, buffers it, and splits on null bytes (\0) to extract complete JSON messages. Each message is parsed and dispatched via the onmessage callback. Outgoing messages are serialized to JSON with a null byte delimiter.

The class uses makeWaitForNextTask to defer message processing to the next microtask, preventing stack overflow with deeply nested message chains.

Usage

Used internally to communicate with browser processes launched with pipe-based stdio transport instead of WebSocket.

Code Reference

Source Location

packages/playwright-core/src/server/pipeTransport.ts (94 lines)

Class Signature

export class PipeTransport implements ConnectionTransport {
  onmessage?: (message: ProtocolResponse) => void;
  constructor(pipeWrite: NodeJS.WritableStream, pipeRead: NodeJS.ReadableStream)
  send(message: ProtocolRequest): void
  close(): void
}

Import

import { PipeTransport } from './server/pipeTransport';

I/O Contract

Inputs

  • pipeWrite: NodeJS.WritableStream -- writable pipe (browser's stdin)
  • pipeRead: NodeJS.ReadableStream -- readable pipe (browser's stdout)

Outputs

  • Dispatches parsed ProtocolResponse objects via onmessage
  • Fires onclose when the pipe stream closes

Protocol

  • Messages are JSON-encoded with null byte (\0) as delimiter

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment