mozilla/pdf.js · error · Error

No response from the AI service.

Error message

No response from the AI service.

What it means

Thrown by StampEditor.mlGuessAltText after awaiting mlManager.guess() for the 'altText' model. It fires only when the guess() promise resolves to a falsy value (null/undefined) rather than a response object. The library treats a completely absent payload as a hard failure of the ML-backed alt-text feature, distinct from a service error or an empty result.

Source

Thrown at src/display/editor/stamp.js:183

      throw new Error("No ML.");
    }
    if (!(await mlManager.isEnabledFor("altText"))) {
      throw new Error("ML isn't enabled for alt text.");
    }
    const { data, width, height } =
      imageData ||
      this.copyCanvas(null, null, /* createImageData = */ true).imageData;
    const response = await mlManager.guess({
      name: "altText",
      request: {
        data,
        width,
        height,
        channels: data.length / (width * height),
      },
    });
    if (!response) {
      throw new Error("No response from the AI service.");
    }
    if (response.error) {
      throw new Error("Error from the AI service.");
    }
    if (response.cancel) {
      return null;
    }
    if (!response.output) {
      throw new Error("No valid response from the AI service.");
    }
    const altText = response.output;
    await this.setGuessedAltText(altText);
    if (updateAltTextData && !this.hasAltTextData()) {
      this.altTextData = { alt: altText, decorative: false };
    }
    return altText;
  }

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Confirm a real mlManager is registered and that isEnabledFor('altText') reflects an actually reachable backend.
  2. Wrap mlGuessAltText() / guess-based flows in try/catch and degrade to the manual alt-text dialog.
  3. Inspect the mlManager.guess implementation to ensure it rejects on network failure rather than resolving undefined.
  4. Check the host environment's telemetry/network logs for the altText request that produced the empty result.

Example fix

// before
const alt = await editor.mlGuessAltText();
// after
try {
  const alt = await editor.mlGuessAltText();
} catch (e) {
  console.warn('Alt-text guess unavailable:', e.message);
  // fall back to the manual alt-text entry dialog
}
Defensive patterns

Strategy: try-catch

Validate before calling

const { mlManager } = editor._uiManager;
if (!mlManager || !(await mlManager.isEnabledFor('altText'))) {
  // skip ML guess entirely; open the manual alt-text dialog instead
}

Type guard

function hasAltTextGuessSupport(editor) {
  const { mlManager } = editor._uiManager ?? {};
  return !!mlManager && typeof mlManager.guess === 'function' && typeof mlManager.isEnabledFor === 'function';
}

Try / catch

try {
  const alt = await editor.mlGuessAltText();
} catch (e) {
  // 'No response from the AI service.' -> backend absent/unreachable
  openAltTextDialog(editor);
}

Prevention

When it happens

Trigger: mlGuessAltText() is called (hasAltTextData() is false, mlManager exists, mlManager.isEnabledFor('altText') is true), mlManager.guess({ name:'altText', request:{data,width,height,channels} }) resolves to null or undefined.

Common situations: The host application wires a stub mlManager whose guess() returns nothing; the AI backend is unreachable and the wrapper resolves empty instead of rejecting; a version mismatch between the viewer and the ML backend returns no body; the ML feature is half-enabled (enabled flag true but no real backend).

Related errors


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