Skip to content

Commit 2fb50ce

Browse files
authored
prevent traces from breaking mobile app (MetaMask#8586)
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> When calling `trace` returns undefined, trying to catch the promise will break the app. This prevents it. Mobile returns undefined in that callback. ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## Checklist - [X] I've updated the test suite for new or updated code as appropriate - [X] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [X] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [X] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: a small defensive change in telemetry code to tolerate `TraceCallback` implementations that return `undefined`, preventing runtime crashes without affecting asset fetching logic. > > **Overview** > Prevents `AssetsController` telemetry from breaking the app by making `#emitTrace` tolerate `trace` implementations that return `undefined` (only calling `.catch()` when a promise is returned). > > Updates the `assets-controller` changelog with a *Fixed* entry documenting the trace callback handling change. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ee070e4. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent bae33dc commit 2fb50ce

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

packages/assets-controller/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222

2323
- Bump `@metamask/transaction-controller` from `^64.3.0` to `^64.4.0` ([#8585](https://github.com/MetaMask/core/pull/8585))
2424

25+
### Fixed
26+
27+
- Handle trace callback returning `undefined` without throwing ([#8586](https://github.com/MetaMask/core/pull/8586))
28+
2529
## [6.1.0]
2630

2731
### Added

packages/assets-controller/src/AssetsController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ export class AssetsController extends BaseController<
574574
if (!this.#trace) {
575575
return;
576576
}
577-
this.#trace({ name, data, tags }, () => undefined).catch(() => {
577+
this.#trace({ name, data, tags }, () => undefined)?.catch(() => {
578578
// Telemetry failure must not break.
579579
});
580580
}

0 commit comments

Comments
 (0)