microsoft/playwright · error · Error

Cannot serialize result: object reference chain is too long.

Error message

Cannot serialize result: object reference chain is too long.

What it means

Error "Cannot serialize result: object reference chain is too long." thrown in microsoft/playwright.

Source

Thrown at packages/playwright-core/src/server/webkit/webview/wvExecutionContext.ts:123

    if (!handle._objectId)
      return;
    await this._session.send('Runtime.releaseObject', { objectId: handle._objectId });
  }

  shouldPrependErrorPrefix(): boolean {
    return false;
  }
}

function potentiallyUnserializableValue(remoteObject: Protocol.Runtime.RemoteObject): any {
  const value = remoteObject.value;
  const isUnserializable = remoteObject.type === 'number' && ['NaN', '-Infinity', 'Infinity', '-0'].includes(remoteObject.description!);
  return isUnserializable ? js.parseUnserializableValue(remoteObject.description!) : value;
}

function rewriteError(error: Error): Error {
  if (error.message.includes('Object has too long reference chain'))
    throw new Error('Cannot serialize result: object reference chain is too long.');
  if (!js.isJavaScriptErrorInEvaluate(error) && !isSessionClosedError(error))
    return new Error('Execution context was destroyed, most likely because of a navigation.');
  return error;
}

function renderPreview(object: Protocol.Runtime.RemoteObject): string | undefined {
  if (object.type === 'undefined')
    return 'undefined';
  if ('value' in object)
    return String(object.value);

  if (object.description === 'Object' && object.preview) {
    const tokens = [];
    for (const { name, value } of object.preview.properties!)
      tokens.push(`${name}: ${value}`);
    return `{${tokens.join(', ')}}`;
  }
  if (object.subtype === 'array' && object.preview)

View on GitHub (pinned to c8fc3bf8d3)

When it happens

Trigger: Thrown at packages/playwright-core/src/server/webkit/webview/wvExecutionContext.ts:123 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/d70f0dda6eea29f1. Report an issue: GitHub.