fix(spend-permission): await wrapped async util in withTelemetry#362
Open
anilkaracay wants to merge 1 commit into
Open
fix(spend-permission): await wrapped async util in withTelemetry#362anilkaracay wants to merge 1 commit into
anilkaracay wants to merge 1 commit into
Conversation
Collaborator
🟡 Heimdall Review Status
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
withTelemetry(the HOF wrapping the spend-permission utilities) is synchronous and does notawaitthe wrapped call. Because all 8 wrapped utilities are async, the completed telemetryevent fires on promise creation (wrong timing) and async rejections bypass the sync try/catch,
so error telemetry is never logged.
Change
Make the returned wrapper
asyncandawaitthe call inside the existing try/catch, mirroringthe repo's correct sibling HOFs (
withMeasurement,withSignerMeasurement). Thetelemetry === falsepassthrough is preserved. Public behavior is unchanged (the returnedpromise resolves/rejects identically); only internal telemetry timing and error capture are fixed.
Testing
Added first-ever coverage in
withTelemetry.test.ts(6 tests), written test-first:completed event fires only AFTER the wrapped async fn resolves (failed before the fix)
error event is logged on async rejection (failed before the fix)
started fires before completion (regression guard)
telemetry === falsepassthrough returns the raw fn and logs nothingresolved value propagates unchanged
function name derivation
yarn test --run: full suite green (account package 74 files / 1006 tests; the 8 wrappedutilities' existing tests still pass)
yarn format: clean (Biome)yarn build:packages: type-checksCloses #361