Skip to content

Rework error reporting from worker threads so all promises resolve #654

@Balearica

Description

@Balearica

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).

  1. Worker loading language traineddata progress 0 #414
  2. Stuck on "loading language traineddata" #439
  3. Promise catch not triggering #471
  4. Tesseract.recognize promise never resolves on mobile #510
  5. Firefox does not get any results.  #513
  6. When the "corePath" or the "workerPath" cannot be downloaded, there is no way to catch the error #528
  7. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions