Skip to content

"An object could not be cloned" when promise is rejected with an error #44

@cdhowie

Description

@cdhowie

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions