[MWPW-199606]Fix intermittent issue of experiment data not fetched for A/B testing#835
Conversation
|
Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
|
| if (isRetry) { | ||
| await this.dispatchErrorToast('warn_fetch_experiment', null, error.message, true, true, { | ||
| code: 'warn_fetch_experiment', | ||
| desc: error.message, |
There was a problem hiding this comment.
do we need to dispatch the error toast in both the cases?
There was a problem hiding this comment.
Good catch, Vipul. I realized that fetchPageConfig catches all errors internally and always returns {} (https://github.com/adobecom/unity/blob/stage/unitylibs/scripts/utils.js#L351), so the catch block in ensurePageConfig is only ever reached via getExperimentData failure. The isRetry check is to make sure we log the error only when even after the retry target data could not be fetched since at first attempt at page load there is a chance that launch is not ready and also avoid duplicate error messages to be logged. I have removed the check of fetchpageConfig from catch and now logging error only for isRetry.
Problem
A race condition existed between
workflow-acrobat's page config initialization and Adobe Launch (_satellite) not being ready at page load. When the unity block initialized,ensurePageConfigwas fired fire-and-forget, which fetched page config and immediately calledwindow._satellite.track(...)to retrieve Target experiment data. Since_satelliteloads asynchronously, this call would throw aTypeErrorif Launch hadn't initialized yet. The error was caught and swallowed, leavingexperimentDatapermanentlynullfor that session becausepageConfigFetched = truewas already set, preventing any retry when the user actually uploaded a file.Changes
unitylibs/utils/experiment-provider.jswaitForSatellite()pollswindow._satelliteevery 100ms (up to 5 seconds) before invoking_satellite.track(...)_satelliteis already present, rejects with a clear error on timeoutunitylibs/core/workflow/workflow-acrobat/action-binder.jsensurePageConfigto handle the edge case where_satellitetakes longer than 5 seconds or fails for other reasonsgetExperimentDatafailure: resetpageConfigFetched = falseandpageConfigPromise = nullso the existing|| this.ensurePageConfig()guard inhandleFileUploadnaturally triggers a fresh attempt when the user uploadsconst isRetry = !!this.pageConfigLocationto detect first attempt vs user-triggered retry error is only dispatched to Splunk on retry, suppressing noise from the recoverable first-attempt failurefetchPageConfigcatches all errors internally and always returns{}, so the catch block inensurePageConfigis only ever reached viagetExperimentDatafailure. Error is only dispatched to Splunk on retry (isRetry) since the first attempt failure is expected_satellitemay not be loaded yet at page load. Flags are reset on failure to allowensurePageConfigto be retried naturally when the user uploads a file.test/utils/experiment-provider.test.js/test/core/workflow/workflow-acrobat/action-binder.test.jswaitForSatellitepolling and timeout,ensurePageConfigguard, flag reset without Splunk dispatch on first failure, flag reset with Splunk dispatch on retry, and success paths via bothpageConfig.config.targetandtargetCfg.experimentationOnBehavior After Fix
_satelliteready before page config completes_satellitenot ready within 5sTest plan
_satelliteloads before user interaction (happy path)_satelliteis delayed past the 5s timeoutwarn_fetch_experimentSplunk entry is logged only on retry failure, not on initial page load failureResolves: MWPW-199606
Test URLs: