Uncaught error when switching language from back to "detect language" in about:translations
Categories
(Firefox :: Translations, defect)
Tracking
()
People
(Reporter: gabrielchl, Assigned: gabrielchl)
Details
Attachments
(1 file, 1 external file)
|
14.97 KB,
image/png
|
Details |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0
Steps to reproduce:
- go to
about:translations - select any language in both the language from and to dropdowns (e.g. from english to french)
- 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
| Assignee | ||
Updated•2 years ago
|
Comment 1•2 years ago
•
|
||
Nice find Gabriel, thanks for filing this.
"essentially
this.translatorseems 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!
| Assignee | ||
Comment 2•2 years ago
|
||
(In reply to Erik Nordin [:nordzilla] from comment #1)
The issue isn't that
this.translatoris undefined. It's that prior to Bug 1884901, the type ofthis.translatorused to be aPromisethat 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. :)
| Assignee | ||
Comment 3•2 years ago
|
||
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.
Updated•2 years ago
|
Comment 5•2 years ago
|
||
| bugherder | ||
Updated•2 years ago
|
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.
Description
•