Skip to content

Commit 4b6dadb

Browse files
fix: Log unhandled Snap errors (#3157)
Log unhandled Snap errors for easier debugging when a Snap is crashing. This lets developers dig up the actual reason for their Snap being terminated in the logs. --------- Co-authored-by: Maarten Zuidhoorn <[email protected]>
1 parent 6222525 commit 4b6dadb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/snaps-controllers/src/snaps/SnapController.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,10 @@ export class SnapController extends BaseController<
15071507
);
15081508
}
15091509

1510-
_onUnhandledSnapError(snapId: string, _error: SnapErrorJson) {
1510+
_onUnhandledSnapError(snapId: string, error: SnapErrorJson) {
1511+
// Log the error that caused the crash
1512+
// so it gets raised to the developer for debugging purposes.
1513+
logError(`Unhandled error from "${snapId}":`, error);
15111514
this.stopSnap(snapId as SnapId, SnapStatusEvents.Crash).catch(
15121515
(stopSnapError) => {
15131516
// TODO: Decide how to handle errors.

0 commit comments

Comments
 (0)