{"record":{"id":"be8198c8ee0d9f55","repo":"mozilla/pdf.js","slug":"the-overlay-is-currently-not-active","errorCode":null,"errorMessage":"The overlay is currently not active.","messagePattern":"The overlay is currently not active\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"web/overlay_manager.js","lineNumber":77,"sourceCode":"        await this.close();\n      } else {\n        throw new Error(\"Another overlay is currently active.\");\n      }\n    }\n    this.#active = dialog;\n    dialog.showModal();\n  }\n\n  /**\n   * @param {HTMLDialogElement} dialog - The overlay's DOM element.\n   * @returns {Promise} A promise that is resolved when the overlay has been\n   *                    closed.\n   */\n  async close(dialog = this.#active) {\n    if (!this.#overlays.has(dialog)) {\n      throw new Error(\"The overlay does not exist.\");\n    } else if (!this.#active) {\n      throw new Error(\"The overlay is currently not active.\");\n    } else if (this.#active !== dialog) {\n      throw new Error(\"Another overlay is currently active.\");\n    }\n    dialog.close();\n    this.#active = null;\n  }\n\n  /**\n   * @param {HTMLDialogElement} dialog - The overlay's DOM element.\n   * @returns {Promise} A promise that is resolved when the overlay has been\n   *                    closed.\n   */\n  async closeIfActive(dialog) {\n    if (this.#active === dialog) {\n      await this.close(dialog);\n    }\n  }\n}","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/web/overlay_manager.js#L59-L95","documentation":"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.","triggerScenarios":"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.","commonSituations":"Duplicate close calls, cancel handler already cleared #active, or closing in response to a stale event.","solutions":["Use closeIfActive(dialog) which safely no-ops when nothing is active.","Guard state before closing: if (OverlayManager.active) await close(dialog).","Avoid calling close from both a button handler and the dialog's own close event."],"exampleFix":"// before\nawait OverlayManager.close(dialog); // throws if nothing active\n\n// after\nawait OverlayManager.closeIfActive(dialog);","handlingStrategy":"fallback","validationCode":"if (OverlayManager.active) {\n  await OverlayManager.close(dialog);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer closeIfActive(dialog) which no-ops when inactive.","Avoid duplicate close handlers.","Guard close calls with OverlayManager.active."],"tags":["overlay","state","lifecycle","ui-utils"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}