Skip to content

[BUG] Failed XHR request after ever tracked item when gathered logs exceed maxBatchSizeInBytes while offline #2034

@peitschie

Description

@peitschie

Description/Screenshot
I'm using ApplicationInsights-JS from within a cordova-based application, which often operates offline for reasonable periods of time.

I've discovered that when the collected offline logs exceed the configured maxBatchSizeInBytes (default is ~10kb), the sender starts trying to post records via XHR after every new log item added. This isn't really expected behaviour, as the Sender knows it's currently offline, and should be using the backoff policies.

Steps to Reproduce

  • OS/Browser: Any. These profiles were captured with Android 12's WebView class
  • SDK Version [e.g. 22]: 2.8.3
  • How you initialized the SDK: All default settings
  • Track ~200 items while being offline (need enough to exceed maxBatchSizeInBytes)

Expected behavior
When offline, no immediate send batches should be attempted, as they can't possibly succeed.

I suspect a check for the offline state should be added here: https://github.com/microsoft/ApplicationInsights-JS/blob/master/channels/applicationinsights-channel-js/src/Sender.ts#L372

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions