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/android.ts:249

  }

  async send(progress: Progress, method: string, params: any = {}): Promise<any> {
    return await progress.race(this._send(method, params));
  }

  private async _send(method: string, params: any = {}): Promise<any> {
    params = {
      ...params,
      // Patch the timeout in, just in case it's missing in one of the commands.
      timeout: params.timeout || 0,
    };
    if (params.androidSelector) {
      params.selector = params.androidSelector;
      delete params.androidSelector;
    }
    const driver = await this._driver();
    if (!driver || this._isClosed)
      throw new Error('Device is closed');
    const id = ++this._lastId;
    const result = new Promise((fulfill, reject) => this._callbacks.set(id, { fulfill, reject }));
    driver.send(JSON.stringify({ id, method, params }));
    return result;
  }

  async close(progress: Progress) {
    await progress.race(this._close());
  }

  private async _close() {
    if (this._isClosed)
      return;
    this._isClosed = true;
    if (this._pollingWebViews)
      clearTimeout(this._pollingWebViews);
    for (const connection of this._browserConnections)
      await connection.close();

View on GitHub (pinned to c8fc3bf8d3)

When it happens

Trigger: Thrown at packages/playwright-core/src/server/android/android.ts:249 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/9b643aeb0d5cdc0d. Report an issue: GitHub.