Closed Bug 1558128 Opened 6 years ago Closed 5 years ago

Report errors from worklet scripts to console

Categories

(Core :: DOM: Core & HTML, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla71
Tracking Status
firefox69 --- wontfix
firefox70 --- wontfix
firefox71 --- fixed

People

(Reporter: karlt, Assigned: karlt)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

WorkerErrorReport::AssignErrorReport() and WorkerErrorReport members look useful for worklets. WorkerErrorNote is only used in this class.
Its LogErrorToConsole methods look suitable for worklets too, with some adjustment for category and kErrorString[].

There is no worklet execution thread event to dispatch for worklets.

If js::ErrorReport::init() returns true, then report() will be non-null.
WarningOnlyErrorReporter() assumes aRep is non-null.
=> aReport is always non-null in WorkerPrivate::ReportError().
=> aToStringResult handling can be moved to WorkerErrorReport::AssignErrorReport().

The stack handling of WorkerPrivate::ReportError() would also be common to worklets.

For the main thread, AutoJSAPI uses xpc::ErrorReport to create and dispatch nsIScriptErrors to nsIConsoleService.

Workers use WorkerErrorReport in response to exceptions and warnings caught by AutoJSAPI to dispatch ErrorEvents and to create and log nsIScriptErrors to nsIConsoleService.

xpc::ErrorReport is also used for errors during worker script loading, and, on main and other threads, to report rejected promises.

WorkerErrorReport has some other worker-specific bits, including mExnType, mErrorNumber, worker parent chains, and logging of messages from ErrorData.
WorkerErrorReport does not set nsIScriptError::errorMessageName, nor nsIScriptError::sourceId.

I'll use xpc::ErrorReport here because that is the existing generic class for dispatching nsIScriptErrors to nsIConsoleService from C++.

Assignee: nobody → karlt
Status: NEW → ASSIGNED
Blocks: 1578623

There is no ErrorEvent dispatched to WorkletGlobalScope.
See also https://github.com/whatwg/html/issues/2611

Depends on D44600

https://drafts.css-houdini.org/worklets/#fetch-and-invoke-a-worklet-script
requires that the addModule() promise is rejected with an "AbortError"
DOMException. https://github.com/w3c/css-houdini-drafts/issues/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

https://phabricator.services.mozilla.com/D44612 proposes more tests for these changes.

Flags: in-testsuite?
Pushed by ktomlinson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1069ae045160 report errors from worklet scripts to console r=baku https://hg.mozilla.org/integration/autoland/rev/13ff86cb281e remove unused local variable r=baku https://hg.mozilla.org/integration/autoland/rev/509d3ab24880 reject addModule() promise with AbortError on failure to parse worklet script and don't suppress SyntaxErrors r=baku
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla71

Since the status are different for nightly and release, what's the status for beta?
For more information, please visit auto_nag documentation.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: