-
-
Notifications
You must be signed in to change notification settings - Fork 261
chore: Replace deprecated error reporting service calls with Messenger.captureException
#7542
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
base: main
Are you sure you want to change the base?
Conversation
| MessengerActions<NetworkControllerMessenger>, | ||
| MessengerEvents<NetworkControllerMessenger> | ||
| >({ namespace: MOCK_ANY_NAMESPACE }); | ||
| rootMessenger.registerActionHandler( |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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.
Gudahtt
left a comment
There was a problem hiding this 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'); |
There was a problem hiding this comment.
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.
Explanation
error-reporting-serviceis deprecated in favour ofMessenger.captureException. There were a couple controllers still using it, which I've fixed in this pull request by replacing the usage ofErrorReportingService:captureExceptionwithMessenger.captureException.References
Checklist
Note
Migrates error reporting from
ErrorReportingService:captureExceptiontoMessenger.captureException, removing the deprecated service and updating types, tests, and changelogs.ErrorReportingService:captureExceptionwith optionalmessenger.captureException?.(...)across@metamask/multichain-account-serviceand@metamask/network-controller(incl. providers and controllers).captureExceptionand remove action delegation forErrorReportingService.ErrorReportingServiceaction/types; usemessenger.captureException?.(...)incorrectInitialState.MultichainAccountWallet,MultichainAccountGroup,MultichainAccountService, andSnapAccountProvider.types.tsto dropErrorReportingServicefrom allowed actions.captureExceptioninstead ofmessenger.call/delegation; update test messengers to includecaptureException.GasFeeController.test.tsand network controller helpers to providecaptureException.@metamask/error-reporting-serviceinmultichain-account-serviceandnetwork-controller.@metamask/error-reporting-servicefrompackage.jsonin affected packages and cleanupyarn.lock.Written by Cursor Bugbot for commit 42d0b9d. This will update automatically on new commits. Configure here.