Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(v8/core): Don't set this.name to new.target.prototype.constructor.name #15222

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/core/src/baseclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,11 +721,10 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
if (DEBUG_BUILD) {
// If something's gone wrong, log the error as a warning. If it's just us having used a `SentryError` for
// control flow, log just the message (no stack) as a log-level log.
const sentryError = reason as SentryError;
if (sentryError.logLevel === 'log') {
logger.log(sentryError.message);
if (reason instanceof SentryError && reason.logLevel === 'log') {
logger.log(reason.message);
} else {
logger.warn(sentryError);
logger.warn(reason);
}
}
return undefined;
Expand Down
8 changes: 0 additions & 8 deletions packages/core/src/utils-hoist/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import type { ConsoleLevel } from '../types-hoist';

/** An error emitted by Sentry SDKs and related utilities. */
export class SentryError extends Error {
/** Display name of this error instance. */
public name: string;

public logLevel: ConsoleLevel;

public constructor(
Expand All @@ -13,11 +10,6 @@ export class SentryError extends Error {
) {
super(message);

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