garrytan/gstack · error · Error

Usage: frame --url <pattern>

Error message

Usage: frame --url <pattern>

What it means

When `frame` is called with `--url`, the command expects a pattern string, escapes it with `escapeRegExp`, compiles a `RegExp`, and calls `page.frame({ url: ... })` (lines 1017-1018). If the pattern is missing the regex cannot be built.

Source

Thrown at browse/src/meta-commands.ts:1018

    // ─── Frame ───────────────────────────────────────
    case 'frame': {
      const target = args[0];
      if (!target) throw new Error('Usage: frame <selector|@ref|--name name|--url pattern|main>');

      if (target === 'main') {
        bm.setFrame(null);
        bm.clearRefs();
        return 'Switched to main frame';
      }

      const page = bm.getPage();
      let frame: Frame | null = null;

      if (target === '--name') {
        if (!args[1]) throw new Error('Usage: frame --name <name>');
        frame = page.frame({ name: args[1] });
      } else if (target === '--url') {
        if (!args[1]) throw new Error('Usage: frame --url <pattern>');
        frame = page.frame({ url: new RegExp(escapeRegExp(args[1])) });
      } else {
        // CSS selector or @ref for the iframe element
        const resolved = await bm.resolveRef(target);
        const locator = 'locator' in resolved ? resolved.locator : page.locator(resolved.selector);
        const elementHandle = await locator.elementHandle({ timeout: 5000 });
        frame = await elementHandle?.contentFrame() ?? null;
        await elementHandle?.dispose();
      }

      if (!frame) throw new Error(`Frame not found: ${target}`);
      bm.setFrame(frame);
      bm.clearRefs();
      return `Switched to frame: ${frame.url()}`;
    }

    // ─── UX Audit ─────────────────────────────────────
    case 'ux-audit': {

View on GitHub (pinned to 94993f7401)

Solutions

  1. Provide a pattern: `browse frame --url 'cdn\.example\.com/player'`.
  2. The pattern is regex-escaped, so literal dots/slashes are fine — no need to double-escape.
  3. If matching by name is easier, switch to `--name`.

Example fix

// before
browse frame --url
// after
browse frame --url 'embed\.example\.com'
Defensive patterns

Strategy: validation

Validate before calling

if (args[0] === '--url' && !args[1]) {
  throw new Error('frame --url requires a URL pattern argument');
}

Prevention

When it happens

Trigger: `browse frame --url` with no following token.

Common situations: Truncated command, or the URL pattern was a shell variable that expanded to empty.

Related errors


AI-assisted analysis of garrytan/gstack@94993f7401 (2026-08-12). Data as JSON: /api/errors/f1db76a054172233. Report an issue: GitHub.