mozilla/pdf.js · warning · Error

The overlay is currently not active.

Error message

The overlay is currently not active.

What it means

Thrown by OverlayManager.close when no overlay is currently active (this.#active is falsy) but the dialog exists in the registry. close() refuses to operate without an active modal.

Source

Thrown at web/overlay_manager.js:77

        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.");
    } else if (!this.#active) {
      throw new Error("The overlay is currently not active.");
    } else if (this.#active !== dialog) {
      throw new Error("Another overlay is currently active.");
    }
    dialog.close();
    this.#active = null;
  }

  /**
   * @param {HTMLDialogElement} dialog - The overlay's DOM element.
   * @returns {Promise} A promise that is resolved when the overlay has been
   *                    closed.
   */
  async closeIfActive(dialog) {
    if (this.#active === dialog) {
      await this.close(dialog);
    }
  }
}

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Use closeIfActive(dialog) which safely no-ops when nothing is active.
  2. Guard state before closing: if (OverlayManager.active) await close(dialog).
  3. Avoid calling close from both a button handler and the dialog's own close event.

Example fix

// before
await OverlayManager.close(dialog); // throws if nothing active

// after
await OverlayManager.closeIfActive(dialog);
Defensive patterns

Strategy: fallback

Validate before calling

if (OverlayManager.active) {
  await OverlayManager.close(dialog);
}

Prevention

When it happens

Trigger: Calling close(dialog) on a registered dialog when nothing is open (e.g. close called twice, or before open). close(dialog) with dialog passed explicitly still hits this if #active is null.

Common situations: Duplicate close calls, cancel handler already cleared #active, or closing in response to a stale event.

Related errors


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