Closed Bug 1810582 Opened 2 years ago Closed 1 years ago

Introduce a new nsIConsoleService.callFunctionAndLogException helper (to log the full error stack on exception originated from a call to WebExtensions API listeners)

Categories

(WebExtensions :: Developer Tools, enhancement, P2)

enhancement

Tracking

(firefox115 fixed)

RESOLVED FIXED
115 Branch
Tracking Status
firefox115 --- fixed

People

(Reporter: rpl, Assigned: ochameau)

References

(Blocks 1 open bug)

Details

(Whiteboard: [addons-jira])

Attachments

(1 file, 2 obsolete files)

In Bug 1792559 we are planning to make the exception raised by WebExtensions API event listener visible again in the AddonDebugging window, by re-creating the error caught internally and log it to the console service with the innerWindowID associated to the extension page that has originated the exception.

Unfortunately by just using the internals we have currently available (nsIScriptError.initWithWindowID + Services.console.logMessage) the resulting error visible in the AddonDebugging window will include only an incomplete error stack (limited to filename, row and column number for the last most recent component of the error's stack) and so we agreed to still proceed with the approach from Bug 1792559's (D166461)[https://phabricator.services.mozilla.com/D166461] so that the AddonDebugging window can at least show to the extension developers that there was an error originated by the call to the API event listener, but to look into introducing the additional changes needed to be able to include the complete error stack.

Component: Request Handling → Developer Tools

Note that it might be complex to pass the stack using existing nsIScriptError pipeline.
There might be creative ways to pass the exception, with its stack directly to DevTools JS code.
JavaScript errors are typically handled by ErrorMessageWatcher:
https://searchfox.org/mozilla-central/rev/d39a17381a14606032f7b8e82789bf281beb1241/devtools/server/actors/resources/error-messages.js#38
which currently uses this nsIConsoleListenerWatcher sub class:
https://searchfox.org/mozilla-central/rev/d39a17381a14606032f7b8e82789bf281beb1241/devtools/server/actors/resources/utils/nsi-console-listener-watcher.js#34-55
itself currently using the nsIConsoleService to listen and retrieve existing messages.

If you are fine loosing errors that happens before devtools are opened you might notify JS code by some other means JS to JS. (observer service?).

Assignee: nobody → lgreco
Status: NEW → ASSIGNED
Severity: -- → N/A
Priority: -- → P2
Whiteboard: [addons-jira]
Attachment #9313539 - Attachment description: Bug 1810582 - [devtools] WIP ConsoleService helper APIs → Bug 1810582 - [devtools] Implements nsIConsoleService.callFunctionAndLogException.
Attachment #9312596 - Attachment is obsolete: true
Attachment #9314608 - Attachment description: WIP: Bug 1810582 - Use new helper to call callback and log exception in BaseContext applySafeWithoutClone and adjust test case expectations. → Bug 1810582 - Use new helper to call callback and log exception in BaseContext applySafeWithoutClone and adjust test case expectations.
Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/87f0c3b8a317 [devtools] Implements nsIConsoleService.callFunctionAndLogException. r=peterv

Looks like a missing include.

Flags: needinfo?(lgreco)
Assignee: lgreco → poirot.alex
Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/02068c2fa1bc [devtools] Implements nsIConsoleService.callFunctionAndLogException. r=peterv

Backed out for causing bustages on nsConsoleService.cpp

Backout link

Push with failures

Failure log

Flags: needinfo?(poirot.alex)

Hopefully this last changeset fixes non-unified build:
https://treeherder.mozilla.org/jobs?repo=try&revision=f47581efc03c59e745d707368a78151eb1a418a9
My typicaly try syntax wasn't triggerring non-unified builds.

Flags: needinfo?(poirot.alex)
Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c680821ab5e2 [devtools] Implements nsIConsoleService.callFunctionAndLogException. r=peterv
Status: ASSIGNED → RESOLVED
Closed: 1 years ago
Resolution: --- → FIXED
Target Milestone: --- → 115 Branch
Blocks: 1834835

Comment on attachment 9314608 [details]
Bug 1810582 - Use new helper to call callback and log exception in BaseContext applySafeWithoutClone and adjust test case expectations.

Revision D168138 was moved to bug 1834835. Setting attachment 9314608 [details] to obsolete.

Attachment #9314608 - Attachment is obsolete: true
Summary: Exceptions originated from WebExtensions API listeners should be logged to the console service with the full stack included in the original exception being caught → Introduce a new nsIConsoleService.callFunctionAndLogException helper (to log the full error stack on exception originated from a call to WebExtensions API listeners)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: