openclaw/openclaw · error

viewport exceeds maximum of

Error message

viewport ${label} exceeds maximum of ${ACT_MAX_VIEWPORT_DIMENSION}

What it means

Thrown by resolveViewportDimension when a viewport width or height exceeds ACT_MAX_VIEWPORT_DIMENSION (currently 8192). Oversized viewports cause excessive memory allocation, rendering performance degradation, and potential Playwright/browser crashes. The same limit is enforced in the tool schema (optionalPositiveIntegerSchema with maximum) and the CLI resize path.

Solutions

  1. Reduce the viewport dimension to 8192 or below.
  2. Use a standard device descriptor via setDeviceViaPlaywright instead of manual dimensions.
  3. Validate dimensions client-side: Math.min(8192, Math.max(1, value)).

Example fix

// before
await resizeViewportViaPlaywright({ cdpUrl, targetId, width: 16384, height: 8192 });
// after
await resizeViewportViaPlaywright({ cdpUrl, targetId, width: 8192, height: 8192 });
Defensive patterns

Strategy: validation

Validate before calling

const ACT_MAX_VIEWPORT_DIMENSION = 8192;
function validateViewportDimension(value: unknown, label: "width" | "height"): number {
  const n = typeof value === "number" && Number.isFinite(value) ? Math.floor(value) : 0;
  if (n < 1 || n > ACT_MAX_VIEWPORT_DIMENSION) {
    throw new Error(`viewport ${label} must be between 1 and ${ACT_MAX_VIEWPORT_DIMENSION}`);
  }
  return n;
}

Type guard

function isValidViewportDimension(value: unknown): value is number {
  return typeof value === "number" && Number.isFinite(value) && value >= 1 && value <= 8192;
}

Prevention

When it happens

Trigger: Calling resizeViewportViaPlaywright or a snapshot with viewport options where width or height > 8192. Also triggered by device descriptors with extreme dimensions.

Common situations: Models or configs that pass very large numbers for viewport dimensions. Copy-paste errors where pixel values are multiplied incorrectly. Attempts to emulate 8K+ displays.

Related errors


AI-assisted analysis of openclaw/openclaw@01804a7531 (2026-08-12). Data as JSON: /api/errors/6093cc96e0bdd20f. Report an issue: GitHub.

Appendix: source

Thrown at extensions/browser/src/browser/pw-tools-core.snapshot.ts:62

function resolveBoundedTimeoutMs(
  timeoutMs: number | undefined,
  fallbackMs: number,
  minMs: number,
  maxMs: number,
): number {
  const parsed = parseFiniteNumber(timeoutMs);
  return Math.max(minMs, Math.min(maxMs, Math.floor(parsed ?? fallbackMs)));
}

function resolveSnapshotTimeoutMs(timeoutMs: number | undefined): number {
  return resolveBoundedTimeoutMs(timeoutMs, 5_000, 500, 60_000);
}

function resolveViewportDimension(value: unknown, label: "width" | "height"): number {
  const dimension = resolveIntegerOption(value, 1, { min: 1 });
  if (dimension > ACT_MAX_VIEWPORT_DIMENSION) {
    throw new Error(`viewport ${label} exceeds maximum of ${ACT_MAX_VIEWPORT_DIMENSION}`);
  }
  return dimension;
}

async function collectSnapshotUrls(page: Page): Promise<SnapshotUrlEntry[]> {
  const urls = await page
    .evaluate(() => {
      const seen = new Set<string>();
      const out: SnapshotUrlEntry[] = [];
      for (const anchor of Array.from(document.querySelectorAll("a[href]"))) {
        const href = anchor instanceof HTMLAnchorElement ? anchor.href : "";
        if (!href || seen.has(href)) {
          continue;
        }
        const text =
          (anchor.textContent || anchor.getAttribute("aria-label") || "")
            .replace(/\s+/g, " ")
            .trim()

View on GitHub (pinned to 01804a7531)