Skip to content

Commit a0470da

Browse files
authored
ref(v8/core): Don't set this.name to new.target.prototype.constructor.name (#15222)
Backport, fixes #15214
1 parent 4574acc commit a0470da

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

packages/core/src/baseclient.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -721,11 +721,10 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
721721
if (DEBUG_BUILD) {
722722
// If something's gone wrong, log the error as a warning. If it's just us having used a `SentryError` for
723723
// control flow, log just the message (no stack) as a log-level log.
724-
const sentryError = reason as SentryError;
725-
if (sentryError.logLevel === 'log') {
726-
logger.log(sentryError.message);
724+
if (reason instanceof SentryError && reason.logLevel === 'log') {
725+
logger.log(reason.message);
727726
} else {
728-
logger.warn(sentryError);
727+
logger.warn(reason);
729728
}
730729
}
731730
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)