BlinkID / blinkid-in-browser

BlinkID In-browser SDK for WebAssembly-enabled browsers.
https://microblink.com/blinkid
62 stars 31 forks source link

Throwing error in the event callback will not get picked up by the promise chain #13

Closed sveres closed 4 years ago

sveres commented 4 years ago

https://github.com/BlinkID/blinkid-in-browser/blob/414d183e54f0853495c341b661b4feda43e4078c/src/MicroblinkSDK/worker/WorkerSDKBackend.ts#L496

I think If error is thrown directly in the constructor then its fine, but throwing the error in the onerror's callback will lead to losing the context and the promise will not get rejected. Or do I miss something?

vjekoart commented 4 years ago

Hi @sveres,

You're correct. We've identified this problem and in the upcoming version this error is handled in a different way.

This code has been modified to use Promise.reject() method, so the consumer of BlinkID SDK can catch all errors with Promise mechanism.

That is, when using this approach during integration, all errors can be handled:

    BlinkIDSDK.loadWasmModule(loadSettings).then(
        (sdk) => {
            // SDK is ready
        },
        (error) => {
            console.error("Failed to load SDK!", error);
        }
    );
sveres commented 4 years ago

sounds good @vjekoart , do you have an ETA for this mentioned release?

vjekoart commented 4 years ago

@sveres upcoming version should be released during this or next week

sveres commented 4 years ago

Hi @vjekoart , is there any update on this fix?

vjekoart commented 4 years ago

Hi @sveres ,

We've released BlinkID v5.8.1 which has fix for this problem. Please see changelog for complete list of changes, but keep in mind that version 5.8.1 is minor bugfix, while majority of changes is documented under 5.8.0 section.

Sorry for the delay, we had some unexpected technical challenges :)