Closed Bug 1908545 Opened 2 years ago Closed 2 years ago

Uncaught error when switching language from back to "detect language" in about:translations

Categories

(Firefox :: Translations, defect)

Firefox 128
defect

Tracking

()

VERIFIED FIXED
130 Branch
Tracking Status
firefox130 --- verified
firefox131 --- verified

People

(Reporter: gabrielchl, Assigned: gabrielchl)

Details

Attachments

(1 file, 1 external file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0

Steps to reproduce:

  1. go to about:translations
  2. select any language in both the language from and to dropdowns (e.g. from english to french)
  3. select "Detect language" in the language from dropdown

Actual results:

An uncaught exception is raised in maybeCreateNewTranslator:
Uncaught (in promise) TypeError: this.translator.then is not a function
essentially this.translator seems to have become undefined

Expected results:

It should not throw any errors

Component: Untriaged → Translations

Nice find Gabriel, thanks for filing this.


"essentially this.translator seems to have become undefined"

The issue isn't that this.translator is undefined. It's that prior to Bug 1884901, the type of this.translator used to be a Promise that would return the translator.

I changed it in D204976 so that this.translator is not a Promise, but an actual Translator, and I forgot to remove the Promise machinery from the line that is throwing the error.


This should be an easy fix:

--- a/toolkit/components/translations/content/translations.mjs
+++ b/toolkit/components/translations/content/translations.mjs
@@ -222,7 +222,7 @@ class TranslationsState {
     ) {
       if (this.translator) {
         // The engine is no longer needed.
-        this.translator.then(translator => translator.destroy());
+        this.translator.destroy();
         this.translator = null;
       }
       return;

Feel free to write a patch for it if you want, since you found it!

Severity: -- → S3
Flags: needinfo?(chihonglee777)

(In reply to Erik Nordin [:nordzilla] from comment #1)

The issue isn't that this.translator is undefined. It's that prior to Bug 1884901, the type of this.translator used to be a Promise that would return the translator.

Ahhh this makes sense! I actually thought it might be some race condition thing with the async functions getting called simultaneously lol. Will raise a patch. :)

Flags: needinfo?(chihonglee777)

An earlier change updated this.translator to be a Translator object
instead of a promise that returned one. This patch fixes a line missed
in the original update, which caused erros to be thrown as .then is
not a valid method of Translator.

Assignee: nobody → chihonglee777
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Pushed by enordin@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9eaa5e0d909a Fix uncaught error when detect language is selected in about:translations. r=translations-reviewers,nordzilla
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 130 Branch

Issue is reproducible on a 2024-07-17 Nightly build on Windows 10.
Verified as fixed on Firefox 130.0b2 and Firefox Nightly 131.0a1 on Windows 10, Ubuntu 22, macOS 14.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: