-
Notifications
You must be signed in to change notification settings - Fork 40
Description
It's considered a best practice to only reject promises with an Error
(or derived object). Unfortunately, this breaks operative as errors can't be cloned. This results in an uncaught error within operative's returnResult
in the context of the web worker, leaving the primary thread hanging waiting for a response that will never arrive.
I believe that operative should handle this case somehow. If the error can't be cloned via postMessage
then we need to do something to tell the main thread that the operation failed -- either transfer the error object using JSON (which can serialize errors, albeit without their functions/prototype) or some other kind of operative-specific error that wraps a structured-cloning-compatible version of the rejection error.
As it stands right now, operative's promise interop is all but useless since it is completely unable to proxy rejections back to the main thread.