Skip to content

Event Listeners Stop Processing on Exception #141

@bryanpieperfl

Description

@bryanpieperfl

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

  1. Add a few event listeners
  2. Throw an Error on the 2nd handler
  3. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions