Skip to content

Async custom dispatcher failures bypass retry handling #62

Description

@danishsshaikh

Problem

The SDK supports custom telemetry dispatchers through the dispatcher config option:

dispatcher?: { dispatch: (event: any) => void };

However, custom dispatchers may perform async work such as calling fetch, writing to IndexedDB, or pushing telemetry to a queue.

Currently, TelemetrySyncManager calls the custom dispatcher without await in both the normal sync path and the retry path:

this._config.dispatcher.dispatch(telemetryObj);

If the custom dispatcher returns a rejected Promise, the surrounding try/catch will not catch the failure. This can cause the SDK to treat the dispatch as successful and skip the existing failed-batch retry handling.

Expected behavior

Async custom dispatcher failures should be handled the same way as failures from the default dispatcher:

  • rejected async dispatches should be caught,
  • failed batches should be added to the failed batch queue,
  • retry logic should be triggered.

Suggested fix

  • Update the custom dispatcher type to allow void | Promise<unknown>.
  • Await custom dispatcher calls in both normal sync and retry sync paths.
  • Add a regression test for rejected async custom dispatchers.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions