Skip to content

withTelemetry does not await wrapped async utilities (wrong completion timing, dropped error telemetry) #361

Description

@anilkaracay

Summary

withTelemetry (the HOF wrapping the spend-permission utilities) is a synchronous function
that does not await the wrapped call. Since all wrapped utilities are async, this causes
two telemetry defects for every wrapped utility:

  1. The completed event (logSpendPermissionUtilCompleted) fires the moment the promise is
    created, not when it resolves. Completion timing/duration is therefore wrong.
  2. An async rejection bypasses the synchronous try/catch, so logSpendPermissionUtilError
    is never called and error telemetry is silently lost.

Public behavior is unaffected (the returned promise resolves/rejects identically) — only the
internal telemetry timing and error capture are wrong.

Affected

All 8 wrapped utilities: requestSpendPermission, fetchPermission, fetchPermissions,
prepareRevokeCallData, getPermissionStatus, requestRevoke, getHash, prepareSpendCallData.

Evidence

The repo's two sibling telemetry HOFs, withMeasurement and withSignerMeasurement, already
handle this correctly: they are async and await the handler inside the try/catch.
withTelemetry is the lone outlier.

Proposed fix

Make the returned wrapper async and await the call inside the existing try/catch,
mirroring the two sibling HOFs, while preserving the telemetry === false passthrough.

Location

packages/account-sdk/src/interface/public-utilities/spend-permission/withTelemetry.ts

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