Open toniopelo opened 12 months ago
Explanation:
opencv.js
is built with emscripten v2.0.10 (see here) with the arguments as stated in this build scriptopencv.js
script where opencv
is wrapped in a emscripten surrounding code that allow the actual code to be executed. This wrapper do several things, among these things, it adds this code:
opencv.js
code was formatted with prettier to be more readable.process.on()
calls grab all the uncaughtException
s and unhandledRejection
s you code can throw and re-throw or exit the process.This is what cause these apparently random errors with no details. The original error probably comes from elsewhere in your codebase, but this is handled here by this emscripten
wrapper and re-thrown without details.
Solution:
After several hours of rebuilding the opencv.js
module with a newer version of emscripten
, tweaking the build arguments and so on, I gave up this approach because it failed at runtime for reasons I choose to not investigate due to time constraints (even though I managed to produce several other versions of opencv.js
that didn't contain the process.on()
calls).
I finally ended up by just using my own version of the opencv.js
module and removing the process.on()
calls from it. I used the same version that this package use, but I don't use this package anymore so I can remove these faulty lines from it. I used mirada
as it is done here to have the typescript definitions.
I finally added a process.on('uncaughtException', () => {...})
elsewhere in my codebase to handle properly these errors woth proper logs and all.
I'll keep this issue open as the package is still having this issue and my solution is more a workaround.
While using this package on node, I would have errors thrown in what appeared to be a "random" fashion, without any concrete explanations in the error. It would just output the whole
opencv.js
module minified code and fail.This kind of errors while using
opencv.js
followed me for a while before I took the time to go into a deep investigation of the root cause. I will post as a comment below my explanation and what worked for me for others in my situation.