microsoft/playwright · error · Error

Unknown new child: ${params.guid}

Error message

Unknown new child: ${params.guid}

What it means

Thrown inside the __adopt__ branch of dispatch() when the child guid (params.guid) is not found in _objects. __adopt__ reparents a remote object under a new parent; if the child was already disposed/collected before the adopt event arrived, the lookup fails. A race between disposal and the server-driven reparenting.

Source

Thrown at packages/playwright-core/src/client/connection.ts:277

      }
      return;
    }

    if (debugLogger.isEnabled('channel'))
      debugLogger.log('channel', '<EVENT ' + JSON.stringify(message));
    if (method === '__create__') {
      this._createRemoteObject(guid, params.type, params.guid, params.initializer);
      return;
    }

    const object = this._objects.get(guid);
    if (!object)
      throw new Error(`Cannot find object to "${method}": ${guid}`);

    if (method === '__adopt__') {
      const child = this._objects.get(params.guid);
      if (!child)
        throw new Error(`Unknown new child: ${params.guid}`);
      object._adopt(child);
      return;
    }

    if (method === '__dispose__') {
      object._dispose(params.reason);
      return;
    }

    const validator = findValidator(object._type, method, 'Event');
    (object._channel as any).emit(method, validator(params, '', this._validatorFromWireContext()));
  }

  close(cause?: string) {
    if (this._closedError)
      return;
    this._closedError = new TargetClosedError(cause);
    for (const callback of this._callbacks.values())

View on GitHub (pinned to c8fc3bf8d3)

Solutions

  1. Avoid closing/disposing pages or contexts while adoption-sensitive operations are in flight.
  2. Upgrade to matching client/server versions where this race is internally tolerated.
  3. If seen during teardown, sequence your awaits so navigation/adoption completes before close.
  4. Capture DEBUG=pw:channel to confirm the adopt-after-dispose ordering if reproducible.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await context.waitForEvent('page'); // adoption path
} catch (e) {
  if (/Unknown new child/.test(String(e?.message))) return; // child disposed mid-adopt
  throw e;
}

Prevention

When it happens

Trigger: The server re-parents an object (e.g. a frame or request moves scope) while the client has already disposed that child — typically during navigation, popup adoption, or context teardown. The parent exists (the outer guard passed) but the child does not.

Common situations: Popup adoption racing with page.close(); iframe detach/reattach during navigation; service-worker or shared-worker scope changes; teardown while the server is restructuring the object tree.

Related errors


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