-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
There are currently many issues related to how Tesseract.js handles errors within workers. For example, the issues below are all either directly about promises never resolving, or are more difficult to troubleshoot because promises never resolve (no error message in the main thread).
- Worker loading language traineddata progress 0 #414
- Stuck on "loading language traineddata" #439
- Promise catch not triggering #471
- Tesseract.recognize promise never resolves on mobile #510
- Firefox does not get any results. #513
- When the "corePath" or the "workerPath" cannot be downloaded, there is no way to catch the error #528
- Node.js: Loading corrupted language trained data does not throw an error #602
While we could implement smaller bug fixes for many of these, the larger issue appears to be that error messages are only reported from the worker threads to the main thread when caught and sent using res.reject. This means that any error that does not trigger a res.reject call will not be reported.
https://github.com/naptha/tesseract.js/blob/master/src/createWorker.js#L168-L174
Reworking to use the worker.onerror event would likely be more robust, and make it impossible for error messages to slip through the cracks in the future.