From f80856c3d5581a38b40bf379cbd8d612b59c4843 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Sep 2021 23:11:26 +0000 Subject: [PATCH 1/2] chore:(deps): bump typescript from 4.3.5 to 4.4.2 in /explorer Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.3.5 to 4.4.2. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v4.3.5...v4.4.2) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- explorer/package-lock.json | 14 +++++++------- explorer/package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/explorer/package-lock.json b/explorer/package-lock.json index 50c9d7ecbfc030..7e8135c94ad1fc 100644 --- a/explorer/package-lock.json +++ b/explorer/package-lock.json @@ -50,7 +50,7 @@ "react-scripts": "^4.0.3", "react-select": "^4.3.1", "superstruct": "^0.15.2", - "typescript": "^4.3.5" + "typescript": "^4.4.2" } }, "node_modules/@babel/code-frame": { @@ -22737,9 +22737,9 @@ "integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g==" }, "node_modules/typescript": { - "version": "4.3.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", - "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==", + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz", + "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -43676,9 +43676,9 @@ "integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g==" }, "typescript": { - "version": "4.3.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", - "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==" + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz", + "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==" }, "unicode-canonical-property-names-ecmascript": { "version": "1.0.4", diff --git a/explorer/package.json b/explorer/package.json index 932f57fcea38d5..726881c62257ff 100644 --- a/explorer/package.json +++ b/explorer/package.json @@ -46,7 +46,7 @@ "react-scripts": "^4.0.3", "react-select": "^4.3.1", "superstruct": "^0.15.2", - "typescript": "^4.3.5" + "typescript": "^4.4.2" }, "scripts": { "start": "react-scripts start", From 1ef3bf27c08afb8cee7f51c86a2ec62b1dbd5548 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Fri, 3 Sep 2021 10:45:01 -0700 Subject: [PATCH 2/2] fix error type --- explorer/src/pages/inspector/RawInputCard.tsx | 2 +- .../src/pages/inspector/SimulatorCard.tsx | 4 +- .../providers/stats/solanaClusterStats.tsx | 38 +++++++++++-------- explorer/src/utils/sentry.ts | 18 +++++---- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/explorer/src/pages/inspector/RawInputCard.tsx b/explorer/src/pages/inspector/RawInputCard.tsx index 21f78bba79620c..a4830618ca407a 100644 --- a/explorer/src/pages/inspector/RawInputCard.tsx +++ b/explorer/src/pages/inspector/RawInputCard.tsx @@ -113,7 +113,7 @@ export function RawInput({ setError(undefined); return; } catch (err) { - setError(err.message); + if (err instanceof Error) setError(err.message); } } else { setError(undefined); diff --git a/explorer/src/pages/inspector/SimulatorCard.tsx b/explorer/src/pages/inspector/SimulatorCard.tsx index 62b8341d624e11..134632fd7a878b 100644 --- a/explorer/src/pages/inspector/SimulatorCard.tsx +++ b/explorer/src/pages/inspector/SimulatorCard.tsx @@ -273,7 +273,9 @@ function useSimulator(message: Message) { } catch (err) { console.error(err); setLogs(null); - setError(err.message); + if (err instanceof Error) { + setError(err.message); + } } finally { setSimulating(false); } diff --git a/explorer/src/providers/stats/solanaClusterStats.tsx b/explorer/src/providers/stats/solanaClusterStats.tsx index babd477d864674..f16bffd04a054b 100644 --- a/explorer/src/providers/stats/solanaClusterStats.tsx +++ b/explorer/src/providers/stats/solanaClusterStats.tsx @@ -126,14 +126,16 @@ export function SolanaClusterStatsProvider({ children }: Props) { if (cluster !== Cluster.Custom) { reportError(error, { url }); } - dispatchPerformanceInfo({ - type: PerformanceInfoActionType.SetError, - data: error.toString(), - }); - dispatchDashboardInfo({ - type: DashboardInfoActionType.SetError, - data: error.toString(), - }); + if (error instanceof Error) { + dispatchPerformanceInfo({ + type: PerformanceInfoActionType.SetError, + data: error.toString(), + }); + dispatchDashboardInfo({ + type: DashboardInfoActionType.SetError, + data: error.toString(), + }); + } setActive(false); } }; @@ -149,10 +151,12 @@ export function SolanaClusterStatsProvider({ children }: Props) { if (cluster !== Cluster.Custom) { reportError(error, { url }); } - dispatchPerformanceInfo({ - type: PerformanceInfoActionType.SetError, - data: error.toString(), - }); + if (error instanceof Error) { + dispatchPerformanceInfo({ + type: PerformanceInfoActionType.SetError, + data: error.toString(), + }); + } setActive(false); } }; @@ -169,10 +173,12 @@ export function SolanaClusterStatsProvider({ children }: Props) { if (cluster !== Cluster.Custom) { reportError(error, { url }); } - dispatchDashboardInfo({ - type: DashboardInfoActionType.SetError, - data: error.toString(), - }); + if (error instanceof Error) { + dispatchDashboardInfo({ + type: DashboardInfoActionType.SetError, + data: error.toString(), + }); + } setActive(false); } }; diff --git a/explorer/src/utils/sentry.ts b/explorer/src/utils/sentry.ts index a37cb70a7db1f0..58f1b9ce44a933 100644 --- a/explorer/src/utils/sentry.ts +++ b/explorer/src/utils/sentry.ts @@ -6,13 +6,15 @@ type Tags = } | undefined; -export function reportError(err: Error, tags: Tags) { - console.error(err, err.message); - try { - Sentry.captureException(err, { - tags, - }); - } catch (err) { - // Sentry can fail if error rate limit is reached +export function reportError(err: unknown, tags: Tags) { + if (err instanceof Error) { + console.error(err, err.message); + try { + Sentry.captureException(err, { + tags, + }); + } catch (err) { + // Sentry can fail if error rate limit is reached + } } }