-
Notifications
You must be signed in to change notification settings - Fork 26
Description
I was testing if you have multiple event listeners attached to an event looking to determine what happens if one of them throws an error. Wanted to understand if the subsequent event listener handlers would continue.
Expected Behaviour
When you have multiple handlers attached to an event, if one throws an error, the remaining handlers do get called.
Actual Behaviour
When you have multiple handlers attached to an event, if one throws an error, the remaining do not get called.
Steps to Reproduce
- Add a few event listeners
- Throw an Error on the 2nd handler
- The remaining handlers will not get called
adobeDataLayer.addEventListener('pageView', function(evt) { console.log('EDDL pageView 1st handler'); }); adobeDataLayer.addEventListener('pageView', function(evt) { console.log('EDDL pageView 2nd handler'); throw new Error("EDDL pageView error"); }); adobeDataLayer.addEventListener('pageView', function(evt) { console.log('EDDL pageView 3rd handler'); }); adobeDataLayer.addEventListener('pageView', function(evt) { console.log('EDDL pageView 4th handler'); }); adobeDataLayer.push({ event: 'pageView'});
Platform and Version
Adobe Client Data Layer 2.0.2
Adobe Client Data Layer Extension in Adobe Launch v2.0.3
Logs taken while reproducing problem
VM1407:85 EDDL pageView 1st handler
VM1407:85 EDDL pageView 2nd handler
launch-EN2e353a6bcf6449339e47775da0327ac7.min.js:11 Uncaught Error: EDDL pageView error
at Array. (:8:9)
at t (launch-EN2e353a6bcf6449339e47775da0327ac7.min.js:12:1753)
at launch-EN2e353a6bcf6449339e47775da0327ac7.min.js:12:2529
at Array.forEach ()
at Object.triggerListeners (launch-EN2e353a6bcf6449339e47775da0327ac7.min.js:12:2415)
at Object.event (launch-EN2e353a6bcf6449339e47775da0327ac7.min.js:11:31064)
at n (launch-EN2e353a6bcf6449339e47775da0327ac7.min.js:11:31546)
at launch-EN2e353a6bcf6449339e47775da0327ac7.min.js:11:32132
at Array.forEach ()
at Array.g.push (launch-EN2e353a6bcf6449339e47775da0327ac7.min.js:11:32011)