Closed
Bug 1316323
Opened 8 years ago
Closed 7 years ago
emitOnObject can enter a recursion loop if a listener to the special "*" event type raises an exception.
Categories
(Add-on SDK Graveyard :: General, defect)
Add-on SDK Graveyard
General
Tracking
(Not tracked)
RESOLVED
INCOMPLETE
People
(Reporter: rpl, Unassigned)
Details
If a listener is registered to the SDK `"*"` event and it raises an exception, `emitOnObject` is going to enter into a recursion loop:
- an event of type "X" is sent to a target, and it will be sent to the listeners registered to that event type, but it will be also sent to all the listeners registered to the special event type "*"
- one of the listener registered to "*" event on that target is executed and raises an exception
- the exception is catched by emitOnObject and given the event type is "*" and not "error", emitOnObject is called again with type "error" and the error as an argument
- the event of type "error" is passed to all the listener registered to the event type "error" (if any) and then it will be also passed to all the listeners of "*" with "*" as the new event type (which is where the exception has been raised the first time, and if the listener continues to raise the exception, emitOnObject is going to recurse again)
I briefly tried it locally and it seems that sometimes it achieves to raise a "Too much recursion" exception pretty soon, and sometimes it seems to remain stuck in the recursion (it seems to reach the "Too much recursion" exception at some point but the running Firefox instance seems to be still stuck).
To reproduce the issue, the following javascript snippet seems to be enough:
const tabs = require("sdk/tabs");
tabs.on("*", () => { throw new Error("Fake Exception") });
tabs.on("ready", () => console.log("Tab opened"));
tabs.open("http://mozilla.org");
Comment 1•7 years ago
|
||
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in
before you can comment on or make changes to this bug.
Description
•