Skip to content

retryFailedRequests resends requests with unknown status #1442

@alex-d-jensen

Description

@alex-d-jensen

Describe the bug
When navigating between pages, and sending events on such (using pagehide, beforeunload etc), the retryFailedRequests flag of the tracker is not respected - or just doesn't behave as intended.
No status received causes resending of events, despite retryFailedRequests being set to false.

To Reproduce
2 pages, with the script below on it, looking as such:

// Minimal tracker for testing duplicate event behavior
import { newTracker, trackPageView, trackSelfDescribingEvent } from "@snowplow/browser-tracker";

// Initialize tracker
const tracker = newTracker('sp', 'localhost:9090', {
  appId: 'reprex-app',
  platform: 'web',
  cookieDomain: 'localhost',
  contexts: { webPage: true },
  bufferSize: 1,
  retryFailedRequests: false,
  retryStatusCodes: [],
  eventMethod: 'post',

});

// Event counter
var eventCounter = 0;

// Track page view on load
trackPageView();
console.log('📄 Page loaded, page view sent');

// Send exit event
function sendExitEvent() {
  eventCounter++;

  const exitEvent = {
    schema: 'iglu:com.reprex/page_exit/jsonschema/1-0-0',
    data: {
      page_url: window.location.href,
      page_title: document.title,
      exit_timestamp: new Date().toISOString(),
      event_number: eventCounter
    }
  };

  console.log('🚪 Sending exit event #' + eventCounter);
  trackSelfDescribingEvent({ event: exitEvent });
}

// Unload handlers
window.addEventListener('beforeunload', () => {
  console.log('🎯 beforeunload fired');

});

window.addEventListener('pagehide', () => {
  console.log('🎯 pagehide fired (no duplicate send)');
  sendExitEvent();
});

console.log('🔧 Tracker initialized on:', window.location.href);

And links between the two packages.

When navigating, observe that multiple events are being sent - as those that don't report back a status to the tracker are resent.

Expected behavior
I'd expected the retryFailedRequests flag to be respected, also for events without a known status.

Screenshots

Image Image

These screenshots show both network tab from browser, and snowplow micro instance - the double entries of page_exit are due to events being sent twice (as the first one do not give back status in time).

Desktop (please complete the following information):

  • OS: Tested on MacOS
  • Browser: Only tested on chrome
  • Version: Snowplow versions below:

v_tracker:string"js-4.6.5"
v_collector:string"micro-ssc-2.3.0-memorysink"
v_etl:string"snowplow-micro-2.3.0"

Additional context
I've tried with both the browser and javascript tracker, and both exhibit same behaviour.
I know events on page exit is a difficult thing - but the automatic and unconfigurable behaviour really surprised me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:defectBugs or weaknesses. The issue has to contain steps to reproduce.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions