garrytan/gstack · error · Error

No modification at index ${idx}. History has ${modificationH

Error message

No modification at index ${idx}. History has ${modificationHistory.length} entries${evictedNote}.

What it means

Error "No modification at index ${idx}. History has ${modificationHistory.length} entries${evictedNote}." thrown in garrytan/gstack.

Source

Thrown at browse/src/cdp-inspector.ts:618

    sourceLine,
    timestamp: Date.now(),
    method,
  };

  pushModification(modification);
  return modification;
}

/**
 * Undo a modification by index (or last if no index given).
 */
export async function undoModification(page: Page, index?: number): Promise<void> {
  const idx = index ?? modificationHistory.length - 1;
  if (idx < 0 || idx >= modificationHistory.length) {
    const evictedNote = modHistoryTotalPushed > MOD_HISTORY_CAP
      ? ` (most recent ${MOD_HISTORY_CAP} only — ${modHistoryTotalPushed - MOD_HISTORY_CAP} earlier entries evicted at the cap)`
      : '';
    throw new Error(
      `No modification at index ${idx}. History has ${modificationHistory.length} entries${evictedNote}.`,
    );
  }

  const mod = modificationHistory[idx];

  if (mod.method === 'setStyleTexts') {
    // Try to restore via CDP
    try {
      await modifyStyle(page, mod.selector, mod.property, mod.oldValue);
      // Remove the undo modification from history (it's a restore, not a new mod)
      modificationHistory.pop();
    } catch (err: any) {
      // Fall back to inline restore — CDP may have disconnected or stylesheet changed
      if (!err?.message?.includes('closed') && !err?.message?.includes('Target') && !err?.message?.includes('style') && !err?.message?.includes('not found') && !err?.message?.includes('Element')) throw err;
      await page.evaluate(
        ([sel, prop, val]) => {
          const el = document.querySelector(sel);

View on GitHub (pinned to 94993f7401)

When it happens

Trigger: Thrown at browse/src/cdp-inspector.ts:618 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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