Closed Bug 872267 Opened 12 years ago Closed 12 years ago

EventEmitter stops on errors

Categories

(L20n :: JS Library, defect, P3)

x86
macOS
defect

Tracking

(Not tracked)

RESOLVED WONTFIX

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
How does node get away without any of these solutions? https://github.com/joyent/node/blob/master/lib/events.js#L119
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
Priority: -- → P3
Target Milestone: --- → 1.0
is it a wontfix? If other libraries do that, maybe we should just accept that it's the expected behavior?
Flags: needinfo?(l10n)
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.