Skip to content

[worklets] addModule() should reject a promise with a more specific exception #509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nhiroki opened this issue Nov 7, 2017 · 8 comments · Fixed by #958 or #967
Closed

[worklets] addModule() should reject a promise with a more specific exception #509

nhiroki opened this issue Nov 7, 2017 · 8 comments · Fixed by #958 or #967

Comments

@nhiroki
Copy link
Contributor

nhiroki commented Nov 7, 2017

The current spec defines that addModule() rejects a promise with "AbortError" DOMException in any case:

  1. Reject promise with an "AbortError" DOMException.
    (see https://drafts.css-houdini.org/worklets/#fetch-and-invoke-a-worklet-script)

This obfuscates the reason why addModule() failed and makes it hard to debug. It would be nice to reject it with a more specific exception like "NetworkError" and "SyntaxError".

@nhiroki
Copy link
Contributor Author

nhiroki commented Nov 7, 2017

Filed an issue in crbug: https://bugs.chromium.org/p/chromium/issues/detail?id=782066

@hiroshige-g
Copy link

How about using module script's error to rethrow? (If the module script is non-null)
https://html.spec.whatwg.org/multipage/webappapis.html#concept-script-error-to-rethrow

@nhiroki
Copy link
Contributor Author

nhiroki commented Sep 25, 2018

@hiroshige-g Sounds good.

@bfgeek Would it be possible to change the worklet spec based on hiroshige's suggestion? According to the feedback on chromium's bug tracker, this makes it difficult for developers to use worklets.

(cc/ @majido @surma )

@bfgeek
Copy link
Contributor

bfgeek commented Sep 25, 2018

@nhiroki I won't have time to make the spec change until later, but it sounds good, and you should make the change in chrome. If you cc me on the patch I can make sure it'll work with the spec.

If you like you can always submit a PR to the spec!

Ian

@nhiroki
Copy link
Contributor Author

nhiroki commented Sep 26, 2018

@bfgeek Thanks! I'll make a patch for chrome and try to change the spec.

@nhiroki
Copy link
Contributor Author

nhiroki commented Oct 16, 2018

It turned out that Error objects are not cloneable (see crbug.com/82066#c10 for details) and cannot be passed between threads. It may be necessary to re-construct an Error object on the document side.

@nhiroki nhiroki closed this as completed Oct 16, 2018
@nhiroki nhiroki reopened this Oct 16, 2018
@guest271314
Copy link

Related WebAudio/web-audio-api#1846. A DOMException is thrown at Chromium 72 if the URL passed to .addModule() is a 404 (thrown by import and import()).

@karlt
Copy link

karlt commented Jul 12, 2019

Error objects can now be cloned. See whatwg/html#4268

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Sep 5, 2019
…parse worklet script and don't suppress SyntaxErrors r=baku

https://drafts.css-houdini.org/worklets/#fetch-and-invoke-a-worklet-script
requires that the addModule() promise is rejected with an "AbortError"
DOMException.  w3c/css-houdini-drafts#509 proposes a
more specific error, but that has not been implemented in another browser.

StealExceptionFromJSContext() set ErrorCode to
NS_ERROR_INTERNAL_ERRORRESULT_JS_EXCEPTION if there was a pending exception
(or NS_ERROR_OUT_OF_MEMORY on failure to record the JS exception) or
NS_ERROR_UNCATCHABLE_EXCEPTION if there was no pending exception.
StealNSResult() converted NS_ERROR_INTERNAL_ERRORRESULT_JS_EXCEPTION to
NS_ERROR_DOM_INVALID_STATE_ERR.

Information about the error is lost on conversion of a SyntaxError to the
promise rejection, so allow the SyntaxError to be reported the console.

Depends on D44601

Differential Revision: https://phabricator.services.mozilla.com/D44602

--HG--
extra : moz-landing-system : lando
xeonchen pushed a commit to xeonchen/gecko that referenced this issue Sep 6, 2019
…parse worklet script and don't suppress SyntaxErrors r=baku

https://drafts.css-houdini.org/worklets/#fetch-and-invoke-a-worklet-script
requires that the addModule() promise is rejected with an "AbortError"
DOMException.  w3c/css-houdini-drafts#509 proposes a
more specific error, but that has not been implemented in another browser.

StealExceptionFromJSContext() set ErrorCode to
NS_ERROR_INTERNAL_ERRORRESULT_JS_EXCEPTION if there was a pending exception
(or NS_ERROR_OUT_OF_MEMORY on failure to record the JS exception) or
NS_ERROR_UNCATCHABLE_EXCEPTION if there was no pending exception.
StealNSResult() converted NS_ERROR_INTERNAL_ERRORRESULT_JS_EXCEPTION to
NS_ERROR_DOM_INVALID_STATE_ERR.

Information about the error is lost on conversion of a SyntaxError to the
promise rejection, so allow the SyntaxError to be reported the console.

Depends on D44601

Differential Revision: https://phabricator.services.mozilla.com/D44602
nhiroki added a commit to nhiroki/css-houdini-drafts that referenced this issue Sep 25, 2019
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Oct 4, 2019
…parse worklet script and don't suppress SyntaxErrors r=baku

https://drafts.css-houdini.org/worklets/#fetch-and-invoke-a-worklet-script
requires that the addModule() promise is rejected with an "AbortError"
DOMException.  w3c/css-houdini-drafts#509 proposes a
more specific error, but that has not been implemented in another browser.

StealExceptionFromJSContext() set ErrorCode to
NS_ERROR_INTERNAL_ERRORRESULT_JS_EXCEPTION if there was a pending exception
(or NS_ERROR_OUT_OF_MEMORY on failure to record the JS exception) or
NS_ERROR_UNCATCHABLE_EXCEPTION if there was no pending exception.
StealNSResult() converted NS_ERROR_INTERNAL_ERRORRESULT_JS_EXCEPTION to
NS_ERROR_DOM_INVALID_STATE_ERR.

Information about the error is lost on conversion of a SyntaxError to the
promise rejection, so allow the SyntaxError to be reported the console.

Depends on D44601

Differential Revision: https://phabricator.services.mozilla.com/D44602

UltraBlame original commit: 509d3ab24880efa860a15cd10d8dccd68ba17508
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Oct 4, 2019
…parse worklet script and don't suppress SyntaxErrors r=baku

https://drafts.css-houdini.org/worklets/#fetch-and-invoke-a-worklet-script
requires that the addModule() promise is rejected with an "AbortError"
DOMException.  w3c/css-houdini-drafts#509 proposes a
more specific error, but that has not been implemented in another browser.

StealExceptionFromJSContext() set ErrorCode to
NS_ERROR_INTERNAL_ERRORRESULT_JS_EXCEPTION if there was a pending exception
(or NS_ERROR_OUT_OF_MEMORY on failure to record the JS exception) or
NS_ERROR_UNCATCHABLE_EXCEPTION if there was no pending exception.
StealNSResult() converted NS_ERROR_INTERNAL_ERRORRESULT_JS_EXCEPTION to
NS_ERROR_DOM_INVALID_STATE_ERR.

Information about the error is lost on conversion of a SyntaxError to the
promise rejection, so allow the SyntaxError to be reported the console.

Depends on D44601

Differential Revision: https://phabricator.services.mozilla.com/D44602

UltraBlame original commit: 509d3ab24880efa860a15cd10d8dccd68ba17508
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Oct 4, 2019
…parse worklet script and don't suppress SyntaxErrors r=baku

https://drafts.css-houdini.org/worklets/#fetch-and-invoke-a-worklet-script
requires that the addModule() promise is rejected with an "AbortError"
DOMException.  w3c/css-houdini-drafts#509 proposes a
more specific error, but that has not been implemented in another browser.

StealExceptionFromJSContext() set ErrorCode to
NS_ERROR_INTERNAL_ERRORRESULT_JS_EXCEPTION if there was a pending exception
(or NS_ERROR_OUT_OF_MEMORY on failure to record the JS exception) or
NS_ERROR_UNCATCHABLE_EXCEPTION if there was no pending exception.
StealNSResult() converted NS_ERROR_INTERNAL_ERRORRESULT_JS_EXCEPTION to
NS_ERROR_DOM_INVALID_STATE_ERR.

Information about the error is lost on conversion of a SyntaxError to the
promise rejection, so allow the SyntaxError to be reported the console.

Depends on D44601

Differential Revision: https://phabricator.services.mozilla.com/D44602

UltraBlame original commit: 509d3ab24880efa860a15cd10d8dccd68ba17508
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants