[BUG] BatchEventProcessor stops sending for B/f Cache loads

Is there an existing issue for this?

  • I have searched the existing issues

SDK Version

6.1.0

Current Behavior

When having pages restored from B/f Cache, the BatchEventProcessor stops sending events to the endpoints. This causes a gap in data.

Expected Behavior

Events should continue being send.

Steps To Reproduce

  1. Create an application with a simple setup as described in Optimizely Docs
  2. Send events permanently and monitor the events endpoint
  3. Use Chromes Application > Back/forward cache > Test b/f cache button to simulate page restore
  4. Verify that events are not send anymore

Link to video demonstrating the issue

SDK Type

Browser

Node Version

24.9.0

Browsers impacted

At least Chrome

Link

import './style.css';
import { createInstance, createPollingProjectConfigManager, createBatchEventProcessor } from '@optimizely/optimizely-sdk';

const testingClient = createInstance({
  projectConfigManager: createPollingProjectConfigManager({
    sdkKey: {SDK_KEY},
    updateInterval: 20000,
    autoUpdate: true
  }),
  eventProcessor: createBatchEventProcessor({
    batchSize: 1,
    flushInterval: 1000
  }),
});

testingClient.onReady().then(() => {
  setInterval(() => {
    testingClient.track('search_dom_interactive_ms', '123');
  }, 3000);
});

Code

Running flag

Mismatch

Logs

No response

Severity

No response

Workaround/Solution

Very suboptimal hack to set the state to running (using private properties and is super error prone). Also it seems that this solution does not work in all cases because numbers are still lower than without B/f cache enabled.

window.addEventListener('pageshow', (event) => {
  if (event.persisted) {
    client.eventProcessor.state = 2;
  }
});

Recent Change

No response

Conflicts

No response