Skip to content

Conversation

@Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Dec 19, 2025

Explanation

error-reporting-service is deprecated in favour of Messenger.captureException. There were a couple controllers still using it, which I've fixed in this pull request by replacing the usage of ErrorReportingService:captureException with Messenger.captureException.

References

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
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Migrates error reporting from ErrorReportingService:captureException to Messenger.captureException, removing the deprecated service and updating types, tests, and changelogs.

  • Error reporting migration
    • Replace calls to ErrorReportingService:captureException with optional messenger.captureException?.(...) across @metamask/multichain-account-service and @metamask/network-controller (incl. providers and controllers).
    • Update helper messengers to expose captureException and remove action delegation for ErrorReportingService.
  • Network Controller
    • Remove ErrorReportingService action/types; use messenger.captureException?.(...) in correctInitialState.
  • Multichain Account Service
    • Swap error reporting in MultichainAccountWallet, MultichainAccountGroup, MultichainAccountService, and SnapAccountProvider.
    • Update types.ts to drop ErrorReportingService from allowed actions.
  • Tests
    • Adjust tests to spy on captureException instead of messenger.call/delegation; update test messengers to include captureException.
    • Minor setup changes in GasFeeController.test.ts and network controller helpers to provide captureException.
  • Changelogs
    • Note removal of @metamask/error-reporting-service in multichain-account-service and network-controller.
  • Dependencies
    • Remove @metamask/error-reporting-service from package.json in affected packages and cleanup yarn.lock.

Written by Cursor Bugbot for commit 42d0b9d. This will update automatically on new commits. Configure here.

MessengerActions<NetworkControllerMessenger>,
MessengerEvents<NetworkControllerMessenger>
>({ namespace: MOCK_ANY_NAMESPACE });
rootMessenger.registerActionHandler(
Copy link
Member Author

Choose a reason for hiding this comment

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

This was only added to the test messenger, the controller doesn't actually use captureException.

},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@metamask/error-reporting-service": "^3.0.1",
Copy link
Member Author

Choose a reason for hiding this comment

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

This dependency wasn't used at all.

@Mrtenz Mrtenz marked this pull request as ready for review December 19, 2025 12:29
@Mrtenz Mrtenz requested review from a team as code owners December 19, 2025 12:29
Gudahtt
Gudahtt previously approved these changes Dec 19, 2025
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

One suggestion for the changelogs, otherwise LGTM!


it('creates new accounts if de-synced', async () => {
const { provider, messenger } = setup();
const captureExceptionSpy = jest.spyOn(messenger, 'captureException');
Copy link

Choose a reason for hiding this comment

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

Bug: Test spy timing prevents capturing captureException calls

The setup() function creates serviceMessenger as a child of the root messenger, at which point serviceMessenger.captureException is assigned a reference to the original jest.fn(). The setup() returns the root messenger, not serviceMessenger. When the test creates jest.spyOn(messenger, 'captureException') AFTER setup, it replaces the root messenger's property, but serviceMessenger.captureException still holds the original function reference. Since the provider uses serviceMessenger, the spy never captures the calls, causing test assertions to fail. This differs from the working pattern in MultichainAccountGroup.test.ts and MultichainAccountWallet.test.ts where setup() returns serviceMessenger directly.

Additional Locations (2)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants