microsoft/playwright · error · Error

Device is closed

Error message

Device is closed

What it means

Error "Device is closed" thrown in microsoft/playwright.

Source

Thrown at packages/playwright-core/src/server/android/backendAdb.ts:60

  private _closed = false;

  constructor(serial: string, status: string, host?: string, port?: number) {
    this.serial = serial;
    this.status = status;
    this.host = host;
    this.port = port;
  }

  async init() {
  }

  async close() {
    this._closed = true;
  }

  runCommand(command: string): Promise<Buffer> {
    if (this._closed)
      throw new Error('Device is closed');
    return runCommand(command, this.host, this.port, this.serial);
  }

  async open(command: string): Promise<SocketBackend> {
    if (this._closed)
      throw new Error('Device is closed');
    const result = await open(command, this.host, this.port, this.serial);
    result.becomeSocket();
    return result;
  }
}

async function runCommand(command: string, host: string = '127.0.0.1', port: number = 5037, serial?: string): Promise<Buffer> {
  debug('pw:adb:runCommand')(command, serial);
  const socket = new BufferedSocketWrapper(command, net.createConnection({ host, port }));
  try {
    if (serial) {
      await socket.write(encodeMessage(`host:transport:${serial}`));

View on GitHub (pinned to c8fc3bf8d3)

When it happens

Trigger: Thrown at packages/playwright-core/src/server/android/backendAdb.ts:60 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12). Data as JSON: /api/errors/3c3830a80034692e. Report an issue: GitHub.