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:
- The completed event (
logSpendPermissionUtilCompleted) fires the moment the promise is
created, not when it resolves. Completion timing/duration is therefore wrong.
- 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
Summary
withTelemetry(the HOF wrapping the spend-permission utilities) is a synchronous functionthat does not
awaitthe wrapped call. Since all wrapped utilities areasync, this causestwo telemetry defects for every wrapped utility:
logSpendPermissionUtilCompleted) fires the moment the promise iscreated, not when it resolves. Completion timing/duration is therefore wrong.
try/catch, sologSpendPermissionUtilErroris 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,
withMeasurementandwithSignerMeasurement, alreadyhandle this correctly: they are
asyncandawaitthe handler inside thetry/catch.withTelemetryis the lone outlier.Proposed fix
Make the returned wrapper
asyncandawaitthe call inside the existingtry/catch,mirroring the two sibling HOFs, while preserving the
telemetry === falsepassthrough.Location
packages/account-sdk/src/interface/public-utilities/spend-permission/withTelemetry.ts