Skip to content

fix: handle snaps error #6104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 18, 2025
Merged

fix: handle snaps error #6104

merged 7 commits into from
Jul 18, 2025

Conversation

salimtb
Copy link
Contributor

@salimtb salimtb commented Jul 10, 2025

Explanation

The MultichainAssetsRatesController was experiencing crashes when Snap requests failed due to parameter validation errors.

the error handling was insufficient - when Snap requests failed, the controller will send a sentry error rather than gracefully handling the error and continuing operation.

References

Changelog

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@salimtb salimtb force-pushed the fix/handle-snaps-errors branch from d891711 to 2a9bbd0 Compare July 10, 2025 22:36
@salimtb salimtb marked this pull request as ready for review July 10, 2025 22:43
@salimtb salimtb requested review from a team as code owners July 10, 2025 22:43
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Snap Request Handling Bypass Causes Errors

The fetchHistoricalPricesForAsset method bypasses the new #handleSnapRequest method, directly calling messagingSystem.call. This prevents graceful error handling (logging and returning undefined) for historical price requests, unlike other snap requests, potentially causing crashes and contradicting the PR's goal of improved error handling for all snap requests.

packages/assets-controllers/src/MultichainAssetsRatesController/MultichainAssetsRatesController.ts#L424-L440

try {
const historicalPricesResponse = await this.messagingSystem.call(
'SnapController:handleRequest',
{
snapId: selectedAccount?.metadata.snap?.id as SnapId,
origin: 'metamask',
handler: HandlerType.OnAssetHistoricalPrice,
request: {
jsonrpc: '2.0',
method: HandlerType.OnAssetHistoricalPrice,
params: {
from: asset,
to: currentCaipCurrency,
},
},
},
);

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

@salimtb salimtb merged commit e090991 into main Jul 18, 2025
215 checks passed
@salimtb salimtb deleted the fix/handle-snaps-errors branch July 18, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants