Closed
Bug 872267
Opened 12 years ago
Closed 12 years ago
EventEmitter stops on errors
Categories
(L20n :: JS Library, defect, P3)
Tracking
(Not tracked)
RESOLVED
WONTFIX
1.0
People
(Reporter: zbraniecki, Unassigned)
Details
If EventEmitter's callback throws, EE breaks.
Example code:
var ctx = L20n.getContext();
ctx.addResource('<browser "foo">');
ctx.addEventListener('ready', function() {
console.log(1);
console.log(y); // error
});
ctx.addEventListener('ready', function() {
console.log(2); // never fired
});
ctx.freeze();
Two possible solutions:
- wrap each listener execution in setTimeout
- or try...catch
Comment 1•12 years ago
|
||
How does node get away without any of these solutions?
https://github.com/joyent/node/blob/master/lib/events.js#L119
| Reporter | ||
Comment 2•12 years ago
|
||
it does not.
Code like:
var events = require("events");
var ee = new events.EventEmitter();
ee.addListener('ready', function() {
console.log(1);
console.log(y); // throws
});
ee.addListener('ready', function() {
console.log(2);
});
ee.emit('ready');
console.log('a');
will throw and never reach 2
Updated•12 years ago
|
Priority: -- → P3
Target Milestone: --- → 1.0
| Reporter | ||
Comment 3•12 years ago
|
||
is it a wontfix?
If other libraries do that, maybe we should just accept that it's the expected behavior?
Flags: needinfo?(l10n)
Comment 4•12 years ago
|
||
Yeah, I think it's common behavior. Same happens in twisted in python land, too. If your callback errors, the event loop hangs.
Status: NEW → RESOLVED
Closed: 12 years ago
Flags: needinfo?(l10n)
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•