Skip to content

Commit 4854e38

Browse files
jeffkwohjeffkwoh
jeffkwoh
authored andcommitted
fix: Suppress unexpected Type Error in capturing RouteError
Wraps unreproducible Type Error (missing setter) in Error.message property in a try-catch. Type Error is unreproducible, and when thrown causes intital error to be ignored and the newer and less informative Type Error to be captured by Sentry instead. Currently, a minority of users are affected and certain browser and/or browser extension incompatibility is suspected. Suppression should help in the discovery of the actual errors causing the RouteError and perhaps uncover the root cause of the Type Error. Fixes getsentryGH-16314 Fixes Sentry-JAVASCRIPT-129Q
1 parent a141a2f commit 4854e38

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/sentry/static/sentry/app/views/routeError.jsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,19 @@ class RouteError extends React.Component {
3636

3737
const route = getRouteStringFromRoutes(routes);
3838
if (route) {
39-
error.message = `${error.message}: ${route}`;
39+
/**
40+
* Unexpectedly, error.message would sometimes not have a setter property, causing another exception to be thrown,
41+
* and losing the original error in the process. Wrapping the mutation in a try-catch in an attempt to preserve
42+
* the original error for logging.
43+
* See https://github.com/getsentry/sentry/issues/16314 for more details.
44+
*/
45+
try {
46+
error.message = `${error.message}: ${route}`;
47+
} catch (e) {
48+
if (!(e instanceof TypeError)) {
49+
throw e;
50+
}
51+
}
4052
}
4153
// TODO(dcramer): show something in addition to embed (that contains it?)
4254
// throw this in a timeout so if it errors we dont fall over

0 commit comments

Comments
 (0)