Skip to content

Commit d34e03f

Browse files
authored
ref(core): Don't set this.name to new.target.prototype.constructor.name on SentryError class (#15216)
We did some funky stuff in there that does not seem necessary and can even lead to issues. Fixes #15214.
1 parent d38b938 commit d34e03f

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

packages/core/src/client.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -903,11 +903,10 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
903903
if (DEBUG_BUILD) {
904904
// If something's gone wrong, log the error as a warning. If it's just us having used a `SentryError` for
905905
// control flow, log just the message (no stack) as a log-level log.
906-
const sentryError = reason as SentryError;
907-
if (sentryError.logLevel === 'log') {
908-
logger.log(sentryError.message);
906+
if (reason instanceof SentryError && reason.logLevel === 'log') {
907+
logger.log(reason.message);
909908
} else {
910-
logger.warn(sentryError);
909+
logger.warn(reason);
911910
}
912911
}
913912
return undefined;

packages/core/src/utils-hoist/error.ts

-8
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import type { ConsoleLevel } from '../types-hoist';
22

33
/** An error emitted by Sentry SDKs and related utilities. */
44
export class SentryError extends Error {
5-
/** Display name of this error instance. */
6-
public name: string;
7-
85
public logLevel: ConsoleLevel;
96

107
public constructor(
@@ -13,11 +10,6 @@ export class SentryError extends Error {
1310
) {
1411
super(message);
1512

16-
this.name = new.target.prototype.constructor.name;
17-
// This sets the prototype to be `Error`, not `SentryError`. It's unclear why we do this, but commenting this line
18-
// out causes various (seemingly totally unrelated) playwright tests consistently time out. FYI, this makes
19-
// instances of `SentryError` fail `obj instanceof SentryError` checks.
20-
Object.setPrototypeOf(this, new.target.prototype);
2113
this.logLevel = logLevel;
2214
}
2315
}

0 commit comments

Comments
 (0)