Repository: mozilla/pdf.js
File: src/core/jpx.js (JavaScript)

Code before:
  static setOptions({ handler, wasmUrl }) {
    if (!this.#buffer) {
      this.#wasmUrl = wasmUrl || null;
      if (wasmUrl === null) {
        this.#handler = handler;
      }
    }
  }

  static async #getJsModule(fallbackCallback) {
    if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
      this.#wasmUrl ??= "/build/generic/web/wasm/";
    }
    const path =
      typeof PDFJSDev === "undefined"
        ? `../${this.#wasmUrl}openjpeg_nowasm_fallback.js`
        : `${this.#wasmUrl}openjpeg_nowasm_fallback.js`;

    let instance = null;
    try {
      const mod = await (typeof PDFJSDev === "undefined"
        ? import(path) // eslint-disable-line no-unsanitized/method
        : __non_webpack_import__(path));
      instance = mod.default();
    } catch (e) {
      warn(`JpxImage#instantiateWasm: ${e}`);
    }

    fallbackCallback(instance);
    this.#hasJSFallback = true;
  }

  static async #instantiateWasm(fallbackCallback, imports, successCallback) {
    const filename = "openjpeg.wasm";
    try {
      if (!this.#buffer) {
        if (this.#wasmUrl !== null) {
          this.#buffer = await fetchBinaryData(`${this.#wasmUrl}${filename}`);
        } else {
          this.#buffer = await this.#handler.sendWithPromise(
            "FetchBinaryData",
            { type: "wasmFactory", filename }
          );
        }
      }
      const results = await WebAssembly.instantiate(this.#buffer, imports);
      return successCallback(results.instance);
    } catch (reason) {
      warn(`JpxImage#instantiateWasm: ${reason}`);

      this.#getJsModule(fallbackCallback);

Review comment (suggestion):
```suggestion
      warn(`JpxImage#getJsModule: ${e}`);
```

Code after:
  static setOptions({ handler, wasmUrl }) {
    if (this.#buffer || this.#hasJSFallback || this.#modulePromise) {
      return;
    }
    this.#wasmUrl = wasmUrl || null;
    if (wasmUrl === null) {
      this.#handler = handler;
    }
  }

  static async #getJsModule(fallbackCallback) {
    if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
      this.#wasmUrl ??= "/build/generic/web/wasm/";
    }
    const path =
      typeof PDFJSDev === "undefined"
        ? `../${this.#wasmUrl}openjpeg_nowasm_fallback.js`
        : `${this.#wasmUrl}openjpeg_nowasm_fallback.js`;

    let instance = null;
    try {
      const mod = await (typeof PDFJSDev === "undefined"
        ? import(path) // eslint-disable-line no-unsanitized/method
        : __non_webpack_import__(path));
      instance = mod.default();
    } catch (e) {
      warn(`JpxImage#getJsModule: ${e}`);
    }

    this.#hasJSFallback = true;
    fallbackCallback(instance);
  }

  static async #instantiateWasm(fallbackCallback, imports, successCallback) {
    const filename = "openjpeg.wasm";
    try {
      if (!this.#buffer) {
        if (this.#wasmUrl !== null) {
          this.#buffer = await fetchBinaryData(`${this.#wasmUrl}${filename}`);
        } else {
          this.#buffer = await this.#handler.sendWithPromise(
            "FetchBinaryData",
            { type: "wasmFactory", filename }
          );
        }
      }
      const results = await WebAssembly.instantiate(this.#buffer, imports);
      return successCallback(results.instance);
    } catch (reason) {
      warn(`JpxImage#instantiateWasm: ${reason}`);