mozilla/pdf.js · warning · Error

The overlay is already active.

Error message

The overlay is already active.

What it means

Thrown by OverlayManager.open when the requested dialog is already the active overlay (this.#active === dialog). The manager only allows one active modal at a time, so reopening the currently-shown dialog is rejected.

Source

Thrown at web/overlay_manager.js:57

    dialog.addEventListener("cancel", ({ target }) => {
      if (this.#active === target) {
        this.#active = null;
      }
    });
  }

  /**
   * @param {HTMLDialogElement} dialog - The overlay's DOM element.
   * @returns {Promise} A promise that is resolved when the overlay has been
   *                    opened.
   */
  async open(dialog) {
    if (!this.#overlays.has(dialog)) {
      throw new Error("The overlay does not exist.");
    } else if (this.#active) {
      if (this.#active === dialog) {
        throw new Error("The overlay is already active.");
      } else if (this.#overlays.get(dialog).canForceClose) {
        await this.close();
      } else {
        throw new Error("Another overlay is currently active.");
      }
    }
    this.#active = dialog;
    dialog.showModal();
  }

  /**
   * @param {HTMLDialogElement} dialog - The overlay's DOM element.
   * @returns {Promise} A promise that is resolved when the overlay has been
   *                    closed.
   */
  async close(dialog = this.#active) {
    if (!this.#overlays.has(dialog)) {
      throw new Error("The overlay does not exist.");

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Guard with OverlayManager.active before opening: if (OverlayManager.active !== dialog) await open(dialog).
  2. Debounce or disable the triggering control while the dialog is shown.
  3. Use closeIfActive to tear down before reopening.

Example fix

// before
await OverlayManager.open(dialog); // throws if already open

// after
if (OverlayManager.active !== dialog) {
  await OverlayManager.open(dialog);
}
Defensive patterns

Strategy: validation

Validate before calling

if (OverlayManager.active !== dialog) {
  await OverlayManager.open(dialog);
}

Try / catch

try {
  await OverlayManager.open(dialog);
} catch (e) {
  if (e.message === 'The overlay is already active.') return;
  throw e;
}

Prevention

When it happens

Trigger: Calling open(dialog) on the same element that is currently set as #active (already shown via showModal). Often a double-open race or a UI button that re-triggers open.

Common situations: User double-clicks a button that opens an already-open dialog, or an event handler fires twice without dedup.

Related errors


AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13). Data as JSON: /api/errors/4624a26ffee468a4. Report an issue: GitHub.