microsoft/playwright · error · Error

Cannot find object to "${method}": ${guid}

Error message

Cannot find object to "${method}": ${guid}

What it means

Thrown in dispatch() when an event (not __create__/__adopt__/__dispose__) arrives for a guid not present in _objects. The owning ChannelOwner was already disposed/collected on the client, but the server emitted an event for it before learning of the disposal. This is a benign race in the disposal/event ordering surfaced as a hard throw.

Source

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

          parsedError.details = detailsValidator(errorDetails ?? {}, '', this._validatorFromWireContext());
        callback.reject(parsedError);
      } else {
        const validator = findValidator(callback.type, callback.method, 'Result');
        callback.resolve(validator(result, '', this._validatorFromWireContext()));
      }
      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()));
  }

View on GitHub (pinned to c8fc3bf8d3)

Solutions

  1. Avoid tearing down pages/contexts while high-volume events are in flight; await outstanding operations first.
  2. If reproducible, capture DEBUG=pw:channel to confirm the event-vs-dispose ordering.
  3. Upgrade client/server to the same version — later Playwright builds add guards for this race.
  4. Treat as a known transient if it only appears in teardown paths; isolate teardown from active event sources.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await page.waitForResponse(url);
} catch (e) {
  if (/Cannot find object to/.test(String(e?.message))) {
    // Event raced with disposal; safe to ignore during teardown.
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: An object is disposed (explicit close or GC) and the server simultaneously fires an event (e.g. close, requestfinished, console) — the event arrives at the client after the object left _objects. Common with rapidly closed pages/contexts/frames under heavy event traffic.

Common situations: Closing a page while network events are still streaming; context.dispose() racing with response events; aggressive GC coupled with a chatty page; flaky timing in fast-running suites.

Related errors


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