[css-houdini-drafts] [worklets] There is no way to catch "throw" or "unhandledrejection" (#975)

samad-aghaei has just created a new issue for https://github.com/w3c/css-houdini-drafts:

== [worklets] There is no way to catch "throw" or "unhandledrejection" ==
It seems that we can not handle throw(s) happened in worklets.

```

//index.html
window.onerror = function(event){...}
window.onunhandledrejection = function(event){...}
window.onrejectionhandled = function(event){...}

( async () => {
    //Are Worklets something between incompleted Worker and incompleted Dynamic Module? :-)
    await CSS.paintWorklet.addModule("./module.js")
})()
.catch(console.log)


//myWorklet.js
throw 'myError'
/** SyntaxError is catchable by our async function. eg: break ...

....
//Uncaught myError       index.html:1
                                   ^^^^ 

```
As far as I know, worklets are kind of workers, if so, having `[onerror, onmessage, postmessage, terminate]` methods are expected and should behave asynchronously.

If they are more like dynamic module, we should have the ability of catching unhandled promise rejections. 

Otherwise, can we call a Worklet a synchronous sandboxed "Realm" which they are living in main thread? If yes, still we need to catch all of its errors.

Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/975 using your GitHub account

Received on Tuesday, 24 December 2019 01:58:28 UTC