Skip to content

makeBrowserOfflineTransport not fully compatible with Replay #11207

Closed

Description

@timfish

Problem Statement

My understanding is that Replay relies on the first envelope being received first.

makeBrowserOfflineTransport returns {} when sending of an envelope fails and it's queued which Replay interprets as a successful send:

} catch (e) {
if (store && (await shouldQueue(envelope, e as Error, retryDelay))) {
await store.insert(envelope);
flushWithBackOff();
log('Error sending. Event queued', e as Error);
return {};
} else {

Queued envelopes are re-tried after the next successful send and the order they enter the queue is preserved for re-sending.

However, the issue is that if the first envelope fails and is queued, and then the device comes back online, the second envelope will be sent before the first. This means that with an intermittent connection, envelope order is not always preserved.

Currently queuing of replay envelopes is disabled:

// We don't queue Session Replay envelopes because they are:
// - Ordered and Replay relies on the response status to know when they're successfully sent.
// - Likely to fill the queue quickly and block other events from being sent.
// We also want to drop client reports because they can be generated when we retry sending events while offline.
if (envelopeContainsItemType(env, ['replay_event', 'replay_recording', 'client_report'])) {
return false;
}

Solution Brainstorm

This only impacts if there is no connection (or a failure) for only the very first envelope. Not sure of the best solution here. Maybe signal to Replay that the event has been queued?

Activity

  1. jas-kas commented on Apr 3, 2024

    @jas-kas
    Contributor

    @timfish @AbhiPrasad Can we look into making this work after v8 is finalized? 🙏 Thank you

  2. self-assigned this
    on Apr 3, 2024
  3. timfish commented on Apr 3, 2024

    @timfish
    CollaboratorAuthor

    We might need to think about this before v8 because it could include breaking changes

  4. AbhiPrasad commented on Apr 3, 2024

    @AbhiPrasad
    Contributor

    We might need to think about this before v8 because it could include breaking changes

    Let's take a look at this now then and see what we need to change

  5. ghost added on Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions