Errors thrown by the extension inside an API event listener do not show up in the console
Categories
(DevTools :: Console, defect)
Tracking
(Not tracked)
People
(Reporter: mckravchyk, Unassigned)
Details
Attachments
(1 file)
3.49 KB,
application/zip
|
Details |
Steps to reproduce:
Try running the following code in either a sidebar frame or a background page:
window.onerror = (
event,
source,
lineno,
colno,
error,
) => {
console.error(error);
};
(function() {
window.browser.tabs.onCreated.addListener(() => {
console.log('throwing in the event listener...');
// It's not thrown. It's not even visible with window.onError and window.onUnhandledPromiseRejection
throw new Error('thrown in the event listener');
// The error never makes it to the console, but the code execution stops. The error can also
// be caught
console.log('after throw');
});
throw new Error('thrown in the top scope'); // ok
// Errors thrown in promises and DOM event listeners are visible
}());
Actual results:
Notice that when you create a new tab, only the console.log prior to the error thrown is visible in the console. The error does not show up in the console, despite occurring and stopping further code execution (it can be caught too). The error does not even show in window.onerror
callback.
There's no way to detect an error and it makes debugging much harder, i.e. I have spent an hour investigating something that would normally immediately show up as an error :(
Expected results:
Any error thrown should appear in the console
I have found similar issues but they are from a decade ago.
Reproduced in 106.0.5 and 107.0.b9 (Linux)
Comment 1•2 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'DevTools::Console' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 2•2 years ago
|
||
Hello Maciej,
Can you see those in the webextension toolbox (using about:debugging#/runtime/this-firefox and inspecting the extension that is throwing)
Reporter | ||
Comment 3•2 years ago
|
||
Hello Nicolas,
no, no errors are showing there.
Reporter | ||
Comment 5•2 years ago
|
||
I'm attaching a sample extension that is affected by this problem. It loads panel.js script in both the Sidebar and as a background script.
Steps to reproduce:
- Load the extension
- Open the console for any context
- Create a new tab
- Notice "Throwing in the event listener..." x2
- Notice that no error has been caught anywhere, even with window.onerror and that the execution is stopped, indicating that the error was thrown
Comment 6•2 years ago
|
||
(In reply to Julian Descottes [:jdescottes] from comment #4)
Nicolas, can you try to reproduce?
Sorry about the lag. Yes I can reproduce.
We're hitting https://searchfox.org/mozilla-central/rev/df68a65540f2227e27a12ed0b491188e2927f6d5/devtools/server/actors/resources/error-messages.js#81-83
if (!message.innerWindowID) {
return false;
}
as message.innerWindowID
is 0
.
Alex, does that look similar to the work you did recently around webextension logs ? I seem to recall you did something to put the right innerWindowID
on some messages ?
Comment 7•2 years ago
|
||
I think it will be fixed by bug 1792559.
Luca, could you confirm?
Comment 8•2 years ago
|
||
(In reply to Alexandre Poirot [:ochameau] from comment #7)
I think it will be fixed by bug 1792559.
Luca, could you confirm?
yes it is, they are technically duplicate of each other, investigating Bug 1792559 have confirmed that the issue is the same for any WebExtensions API events not just webRequest.
Would you be ok from your perspective if we close this as a duplicate of Bug 1792559 (and tweak Bug 1792559 summary to make it clear is not specific to webRequest listeners)?
Comment 9•2 years ago
|
||
Sure, your are on it, do whatever makes sense in term of bugzilla dependencies.
Updated•2 years ago
|
Description
•