adobe / adobe/adobe-client-data-layer
Uncaught errors when adobeDataLayer exists but getState() is not yet available
- Dominant language
- JavaScript
- Stars
- 122
- Forks
- 28
- PR merge metrics
- No merged PRs in 30d
Description
Note: this is an issue in the gcoe-adobe-client-data-layer Launch extension, not in Adobe's core adobe-client-data-layer open-source library. The core library's documented pattern already handles this correctly; this extension's bundled data element module does not.
Expected behavior: The "Data Layer Computed State" data element should safely return undefined (or defer) when the Adobe Client Data Layer library hasn't finished upgrading window.adobeDataLayer from its initial stub array into the full instance, instead of throwing an error.
Actual behavior: A data element using this module throws TypeError: t.getState is not a function when it evaluates before the ACDL library has finished initializing.
In my scenario: I was using a clean container very light in rules and file size.
Contributor guide
Research direction
Locate the gcoe-adobe-client-data-layer Launch extension's bundled data element module and reproduce evaluation while window.adobeDataLayer is still its initial stub array. Confirm that the "Data Layer Computed State" element no longer throws when getState() is unavailable and instead returns undefined or defers safely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100