Repository navigation
Lingua web edition: wait for the translation (it showed [object Promise]) - #131
Merged
Merged
Conversation
…le translate showed [object Promise] and said Translated. even when the gateway had not answered)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while trying a translation on Lingua's page for the new Mac and Android apps.
Fault.
CaptionPipeline.update()is synchronous (ported from the laptop app), but in the browser the translate function is a network call that returns a promise. Web capture (web.html) and Mobile translate (mobile.html, text and screenshot) put that promise into the transcript: every line read[object Promise], and the status said "Translated." whether or not the gateway had answered. Read picture awaits its calls and was not affected. Share to phone serves the same pages.Fix.
CaptionPipeline.updateAsync()waits for every translationupdate()started and puts the text into the lines and the cache; when one fails, what did not arrive is forgotten so the next try asks again, and the error reaches the page's own failure message. The two pages call it. Offline cache name goes to v6.Tried on this branch in WebKit and in Chromium as a Pixel 7, with a stand-in gateway on the Mac (OpenAI chat format, CORS): two sentences translated and shown one under the other; with the gateway gone the status says "Translate failed: Could not reach the gateway..." and the transcript keeps the earlier lines. On the live page before the fix both engines showed
[object Promise].