mozilla/pdf.js · warning · Error

Another overlay is currently active.

Error message

Another overlay is currently active.

What it means

Thrown by OverlayManager.open when another overlay is currently active and the requested dialog was registered without canForceClose=true. The manager enforces single-active-modal semantics; non-force-close dialogs cannot preempt an active one.

Source

Thrown at web/overlay_manager.js:61

      }
    });
  }

  /**
   * @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.");
    } 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.");

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Close the active overlay first: await OverlayManager.close(); then open the new one.
  2. Register the new dialog with canForceClose=true if it should preempt: register(dialog, true).
  3. Use closeIfActive to dismiss the active dialog before opening another.

Example fix

// before
await OverlayManager.register(dialogB); // canForceClose=false
await OverlayManager.open(dialogB); // throws if A active

// after
await OverlayManager.register(dialogB, /* canForceClose = */ true);
await OverlayManager.open(dialogB);
Defensive patterns

Strategy: validation

Validate before calling

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

Prevention

When it happens

Trigger: Calling open(dialogB) while dialogA is active, where dialogB was registered with register(dialogB) (canForceClose defaults to false).

Common situations: Two overlapping dialogs (e.g. password prompt open while trying to open the print dialog) where the second was not flagged canForceClose.

Related errors


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