From 8130e68f674c7f70f8aeb3732c526d5dd1cbe0f7 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 3 Dec 2024 09:06:46 +0100 Subject: [PATCH 1/4] ref: Refactor some more `any` types --- packages/angular/src/tracing.ts | 17 +++++++---------- .../browser/src/integrations/globalhandlers.ts | 12 ++++++++---- packages/browser/src/sdk.ts | 1 + packages/core/src/api.ts | 1 + packages/core/src/baseclient.ts | 6 ++---- packages/core/src/exports.ts | 9 ++------- packages/core/src/fetch.ts | 2 -- .../core/src/integrations/functiontostring.ts | 3 +-- packages/core/src/metrics/aggregator.ts | 2 +- packages/core/src/server-runtime-client.ts | 3 +-- packages/core/src/sessionflusher.ts | 7 ++----- .../instrument/globalUnhandledRejection.ts | 1 - packages/core/src/utils-hoist/logger.ts | 6 ++---- packages/core/src/utils-hoist/misc.ts | 1 - packages/core/src/utils-hoist/object.ts | 7 ++++--- packages/core/src/utils-hoist/string.ts | 3 +-- .../src/utils-hoist/vendor/supportsHistory.ts | 6 ++---- packages/nestjs/src/decorators.ts | 18 ++++++------------ .../src/integrations/onunhandledrejection.ts | 10 ++-------- packages/node/src/utils/errorhandling.ts | 2 +- packages/replay-internal/src/util/throttle.ts | 2 +- packages/solid/src/errorboundary.ts | 6 ++---- 22 files changed, 47 insertions(+), 78 deletions(-) diff --git a/packages/angular/src/tracing.ts b/packages/angular/src/tracing.ts index 4fcfbeffb0af..c347a5e19b2e 100644 --- a/packages/angular/src/tracing.ts +++ b/packages/angular/src/tracing.ts @@ -271,8 +271,9 @@ export class TraceDirective implements OnInit, AfterViewInit { * @inheritdoc */ public ngAfterViewInit(): void { - if (this._tracingSpan) { - runOutsideAngular(() => this._tracingSpan!.end()); + const span = this._tracingSpan; + if (span) { + runOutsideAngular(() => span.end()); } } } @@ -302,8 +303,7 @@ export function TraceClass(options?: TraceClassOptions): ClassDecorator { /* eslint-disable @typescript-eslint/no-unsafe-member-access */ return target => { const originalOnInit = target.prototype.ngOnInit; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - target.prototype.ngOnInit = function (...args: any[]): ReturnType { + target.prototype.ngOnInit = function (...args: unknown[]): ReturnType { tracingSpan = runOutsideAngular(() => startInactiveSpan({ onlyIfParent: true, @@ -321,8 +321,7 @@ export function TraceClass(options?: TraceClassOptions): ClassDecorator { }; const originalAfterViewInit = target.prototype.ngAfterViewInit; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - target.prototype.ngAfterViewInit = function (...args: any[]): ReturnType { + target.prototype.ngAfterViewInit = function (...args: unknown[]): ReturnType { if (tracingSpan) { runOutsideAngular(() => tracingSpan.end()); } @@ -345,11 +344,9 @@ interface TraceMethodOptions { * Decorator function that can be used to capture a single lifecycle methods of the component. */ export function TraceMethod(options?: TraceMethodOptions): MethodDecorator { - // eslint-disable-next-line @typescript-eslint/ban-types - return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => { + return (_target: unknown, propertyKey: string | symbol, descriptor: PropertyDescriptor) => { const originalMethod = descriptor.value; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - descriptor.value = function (...args: any[]): ReturnType { + descriptor.value = function (...args: unknown[]): ReturnType { const now = timestampInSeconds(); runOutsideAngular(() => { diff --git a/packages/browser/src/integrations/globalhandlers.ts b/packages/browser/src/integrations/globalhandlers.ts index 1f0d0a4b35c1..abb768082c3a 100644 --- a/packages/browser/src/integrations/globalhandlers.ts +++ b/packages/browser/src/integrations/globalhandlers.ts @@ -153,8 +153,12 @@ function _eventFromRejectionWithPrimitive(reason: Primitive): Event { }; } -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function _enhanceEventWithInitialFrame(event: Event, url: any, line: any, column: any): Event { +function _enhanceEventWithInitialFrame( + event: Event, + url: string | undefined, + line: number | undefined, + column: number | undefined, +): Event { // event.exception const e = (event.exception = event.exception || {}); // event.exception.values @@ -166,8 +170,8 @@ function _enhanceEventWithInitialFrame(event: Event, url: any, line: any, column // event.exception.values[0].stacktrace.frames const ev0sf = (ev0s.frames = ev0s.frames || []); - const colno = isNaN(parseInt(column, 10)) ? undefined : column; - const lineno = isNaN(parseInt(line, 10)) ? undefined : line; + const colno = column; + const lineno = line; const filename = isString(url) && url.length > 0 ? url : getLocationHref(); // event.exception.values[0].stacktrace.frames diff --git a/packages/browser/src/sdk.ts b/packages/browser/src/sdk.ts index a033a4c848d2..caddc31bc167 100644 --- a/packages/browser/src/sdk.ts +++ b/packages/browser/src/sdk.ts @@ -198,6 +198,7 @@ export function init(browserOptions: BrowserOptions = {}): Client | undefined { * All properties the report dialog supports */ export interface ReportDialogOptions { + // TODO(v9): Change this to [key: string]: unknkown; // eslint-disable-next-line @typescript-eslint/no-explicit-any [key: string]: any; eventId?: string; diff --git a/packages/core/src/api.ts b/packages/core/src/api.ts index 548b40a3ce30..23b0306d2e27 100644 --- a/packages/core/src/api.ts +++ b/packages/core/src/api.ts @@ -47,6 +47,7 @@ export function getEnvelopeEndpointWithUrlEncodedAuth(dsn: DsnComponents, tunnel export function getReportDialogEndpoint( dsnLike: DsnLike, dialogOptions: { + // TODO(v9): Change this to [key: string]: unknown; // eslint-disable-next-line @typescript-eslint/no-explicit-any [key: string]: any; user?: { name?: string; email?: string }; diff --git a/packages/core/src/baseclient.ts b/packages/core/src/baseclient.ts index 5d06d539b6ec..c394a0d77a95 100644 --- a/packages/core/src/baseclient.ts +++ b/packages/core/src/baseclient.ts @@ -158,8 +158,7 @@ export abstract class BaseClient implements Client { /** * @inheritDoc */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public captureException(exception: any, hint?: EventHint, scope?: Scope): string { + public captureException(exception: unknown, hint?: EventHint, scope?: Scope): string { const eventId = uuid4(); // ensure we haven't captured this very object before @@ -915,8 +914,7 @@ export abstract class BaseClient implements Client { /** * @inheritDoc */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public abstract eventFromException(_exception: any, _hint?: EventHint): PromiseLike; + public abstract eventFromException(_exception: unknown, _hint?: EventHint): PromiseLike; /** * @inheritDoc diff --git a/packages/core/src/exports.ts b/packages/core/src/exports.ts index 0ae3fa3d2775..cf7e872fb001 100644 --- a/packages/core/src/exports.ts +++ b/packages/core/src/exports.ts @@ -34,11 +34,7 @@ import { parseEventHintOrCaptureContext } from './utils/prepareEvent'; * @param hint Optional additional data to attach to the Sentry event. * @returns the id of the captured Sentry event. */ -export function captureException( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - exception: any, - hint?: ExclusiveEventHintOrCaptureContext, -): string { +export function captureException(exception: unknown, hint?: ExclusiveEventHintOrCaptureContext): string { return getCurrentScope().captureException(exception, parseEventHintOrCaptureContext(hint)); } @@ -73,8 +69,7 @@ export function captureEvent(event: Event, hint?: EventHint): string { * @param name of the context * @param context Any kind of data. This data will be normalized. */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export function setContext(name: string, context: { [key: string]: any } | null): void { +export function setContext(name: string, context: { [key: string]: unknown } | null): void { getIsolationScope().setContext(name, context); } diff --git a/packages/core/src/fetch.ts b/packages/core/src/fetch.ts index 7385298f925c..55ea867a763a 100644 --- a/packages/core/src/fetch.ts +++ b/packages/core/src/fetch.ts @@ -14,8 +14,6 @@ type PolymorphicRequestHeaders = | Array<[string, string]> // the below is not precisely the Header type used in Request, but it'll pass duck-typing | { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key: string]: any; append: (key: string, value: string) => void; get: (key: string) => string | null | undefined; }; diff --git a/packages/core/src/integrations/functiontostring.ts b/packages/core/src/integrations/functiontostring.ts index ddac187ac7c9..cba170bb5722 100644 --- a/packages/core/src/integrations/functiontostring.ts +++ b/packages/core/src/integrations/functiontostring.ts @@ -19,8 +19,7 @@ const _functionToStringIntegration = (() => { // intrinsics (like Function.prototype) might be immutable in some environments // e.g. Node with --frozen-intrinsics, XS (an embedded JavaScript engine) or SES (a JavaScript proposal) try { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - Function.prototype.toString = function (this: WrappedFunction, ...args: any[]): string { + Function.prototype.toString = function (this: WrappedFunction, ...args: unknown[]): string { const originalFunction = getOriginalFunction(this); const context = SETUP_CLIENTS.has(getClient() as Client) && originalFunction !== undefined ? originalFunction : this; diff --git a/packages/core/src/metrics/aggregator.ts b/packages/core/src/metrics/aggregator.ts index b3213ef87f0c..972c6b3336ad 100644 --- a/packages/core/src/metrics/aggregator.ts +++ b/packages/core/src/metrics/aggregator.ts @@ -20,7 +20,7 @@ export class MetricsAggregator implements MetricsAggregatorBase { // that we store in memory. private _bucketsTotalWeight; - // We adjust the type here to add the `unref()` part, as setInterval can technically return a number of a NodeJS.Timer. + // We adjust the type here to add the `unref()` part, as setInterval can technically return a number or a NodeJS.Timer private readonly _interval: ReturnType & { unref?: () => void }; // SDKs are required to shift the flush interval by random() * rollup_in_seconds. diff --git a/packages/core/src/server-runtime-client.ts b/packages/core/src/server-runtime-client.ts index bb0efe6652dc..bc9489406282 100644 --- a/packages/core/src/server-runtime-client.ts +++ b/packages/core/src/server-runtime-client.ts @@ -79,8 +79,7 @@ export class ServerRuntimeClient< /** * @inheritDoc */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - public captureException(exception: any, hint?: EventHint, scope?: Scope): string { + public captureException(exception: unknown, hint?: EventHint, scope?: Scope): string { // Check if `_sessionFlusher` exists because it is initialized (defined) only when the `autoSessionTracking` is enabled. // The expectation is that session aggregates are only sent when `autoSessionTracking` is enabled. // TODO(v9): Our goal in the future is to not have the `autoSessionTracking` option and instead rely on integrations doing the creation and sending of sessions. We will not have a central kill-switch for sessions. diff --git a/packages/core/src/sessionflusher.ts b/packages/core/src/sessionflusher.ts index 317ac8e1ab80..2434023bf797 100644 --- a/packages/core/src/sessionflusher.ts +++ b/packages/core/src/sessionflusher.ts @@ -22,9 +22,8 @@ export class SessionFlusher implements SessionFlusherLike { public readonly flushTimeout: number; private _pendingAggregates: Map; private _sessionAttrs: ReleaseHealthAttributes; - // Cast to any so that it can use Node.js timeout - // eslint-disable-next-line @typescript-eslint/no-explicit-any - private _intervalId: any; + // We adjust the type here to add the `unref()` part, as setInterval can technically return a number or a NodeJS.Timer + private readonly _intervalId: ReturnType & { unref?: () => void }; private _isEnabled: boolean; private _client: Client; @@ -36,9 +35,7 @@ export class SessionFlusher implements SessionFlusherLike { // Call to setInterval, so that flush is called every 60 seconds. this._intervalId = setInterval(() => this.flush(), this.flushTimeout * 1000); - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access if (this._intervalId.unref) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access this._intervalId.unref(); } this._sessionAttrs = attrs; diff --git a/packages/core/src/utils-hoist/instrument/globalUnhandledRejection.ts b/packages/core/src/utils-hoist/instrument/globalUnhandledRejection.ts index 299f32ced711..a81d9ba3c780 100644 --- a/packages/core/src/utils-hoist/instrument/globalUnhandledRejection.ts +++ b/packages/core/src/utils-hoist/instrument/globalUnhandledRejection.ts @@ -1,5 +1,4 @@ import type { HandlerDataUnhandledRejection } from '../../types-hoist'; - import { GLOBAL_OBJ } from '../worldwide'; import { addHandler, maybeInstrument, triggerHandlers } from './handlers'; diff --git a/packages/core/src/utils-hoist/logger.ts b/packages/core/src/utils-hoist/logger.ts index a18b19be6db6..90d306f11434 100644 --- a/packages/core/src/utils-hoist/logger.ts +++ b/packages/core/src/utils-hoist/logger.ts @@ -21,8 +21,7 @@ type LoggerConsoleMethods = Record; /** This may be mutated by the console instrumentation. */ export const originalConsoleMethods: { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key in ConsoleLevel]?: (...args: any[]) => void; + [key in ConsoleLevel]?: (...args: unknown[]) => void; } = {}; /** JSDoc */ @@ -79,8 +78,7 @@ function makeLogger(): Logger { if (DEBUG_BUILD) { CONSOLE_LEVELS.forEach(name => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - logger[name] = (...args: any[]) => { + logger[name] = (...args: Parameters<(typeof GLOBAL_OBJ.console)[typeof name]>) => { if (enabled) { consoleSandbox(() => { GLOBAL_OBJ.console[name](`${PREFIX}[${name}]:`, ...args); diff --git a/packages/core/src/utils-hoist/misc.ts b/packages/core/src/utils-hoist/misc.ts index 5a3190e0f87b..58a416b0ae31 100644 --- a/packages/core/src/utils-hoist/misc.ts +++ b/packages/core/src/utils-hoist/misc.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ import type { Event, Exception, Mechanism, StackFrame } from '../types-hoist'; import { addNonEnumerableProperty } from './object'; diff --git a/packages/core/src/utils-hoist/object.ts b/packages/core/src/utils-hoist/object.ts index f5703feaa1da..c18247a62f55 100644 --- a/packages/core/src/utils-hoist/object.ts +++ b/packages/core/src/utils-hoist/object.ts @@ -94,9 +94,10 @@ export function getOriginalFunction(func: WrappedFunction * * @deprecated This function is deprecated and will be removed in the next major version of the SDK. */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function urlEncode(object: { [key: string]: any }): string { - return Object.keys(object) - .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(object[key])}`) + return Object.entries(object) + .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`) .join('&'); } @@ -237,7 +238,7 @@ function _dropUndefinedKeys(inputValue: T, memoizationMap: Map { return (target: unknown, propertyKey, descriptor: PropertyDescriptor) => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const originalMethod = descriptor.value as (...args: any[]) => Promise; + const originalMethod = descriptor.value as (...args: unknown[]) => Promise; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - descriptor.value = function (...args: any[]) { + descriptor.value = function (...args: unknown[]) { return Sentry.withMonitor( monitorSlug, () => { @@ -31,11 +29,9 @@ export const SentryCron = (monitorSlug: string, monitorConfig?: MonitorConfig): */ export function SentryTraced(op: string = 'function') { return function (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const originalMethod = descriptor.value as (...args: any[]) => Promise | any; // function can be sync or async + const originalMethod = descriptor.value as (...args: unknown[]) => Promise | unknown; // function can be sync or async - // eslint-disable-next-line @typescript-eslint/no-explicit-any - descriptor.value = function (...args: any[]) { + descriptor.value = function (...args: unknown[]) { return startSpan( { op: op, @@ -64,11 +60,9 @@ export function SentryTraced(op: string = 'function') { */ export function SentryExceptionCaptured() { return function (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const originalCatch = descriptor.value as (exception: unknown, host: unknown, ...args: any[]) => void; + const originalCatch = descriptor.value as (exception: unknown, host: unknown, ...args: unknown[]) => void; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - descriptor.value = function (exception: unknown, host: unknown, ...args: any[]) { + descriptor.value = function (exception: unknown, host: unknown, ...args: unknown[]) { if (isExpectedError(exception)) { return originalCatch.apply(this, [exception, host, ...args]); } diff --git a/packages/node/src/integrations/onunhandledrejection.ts b/packages/node/src/integrations/onunhandledrejection.ts index ecf89960cbd6..4a7c7a1fe83d 100644 --- a/packages/node/src/integrations/onunhandledrejection.ts +++ b/packages/node/src/integrations/onunhandledrejection.ts @@ -63,13 +63,8 @@ export function makeUnhandledPromiseHandler( /** * Handler for `mode` option - */ -function handleRejection( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - reason: any, - options: OnUnhandledRejectionOptions, -): void { +function handleRejection(reason: unknown, options: OnUnhandledRejectionOptions): void { // https://github.com/nodejs/node/blob/7cf6f9e964aa00772965391c23acda6d71972a9a/lib/internal/process/promises.js#L234-L240 const rejectionWarning = 'This error originated either by ' + @@ -81,8 +76,7 @@ function handleRejection( if (options.mode === 'warn') { consoleSandbox(() => { console.warn(rejectionWarning); - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - console.error(reason && reason.stack ? reason.stack : reason); + console.error(reason && typeof reason === 'object' && 'stack' in reason ? reason.stack : reason); }); } else if (options.mode === 'strict') { consoleSandbox(() => { diff --git a/packages/node/src/utils/errorhandling.ts b/packages/node/src/utils/errorhandling.ts index 8eda429ba38e..c99da5c0d04f 100644 --- a/packages/node/src/utils/errorhandling.ts +++ b/packages/node/src/utils/errorhandling.ts @@ -7,7 +7,7 @@ const DEFAULT_SHUTDOWN_TIMEOUT = 2000; /** * @hidden */ -export function logAndExitProcess(error: Error): void { +export function logAndExitProcess(error: unknown): void { consoleSandbox(() => { // eslint-disable-next-line no-console console.error(error); diff --git a/packages/replay-internal/src/util/throttle.ts b/packages/replay-internal/src/util/throttle.ts index 66ce6ed0cdfb..ef0a119d7468 100644 --- a/packages/replay-internal/src/util/throttle.ts +++ b/packages/replay-internal/src/util/throttle.ts @@ -10,7 +10,7 @@ export const SKIPPED = '__SKIPPED'; * or else the return value of the original function. */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -export function throttle any>( +export function throttle any>( fn: T, maxCount: number, durationSeconds: number, diff --git a/packages/solid/src/errorboundary.ts b/packages/solid/src/errorboundary.ts index 8a1ad0efa902..f2600313a723 100644 --- a/packages/solid/src/errorboundary.ts +++ b/packages/solid/src/errorboundary.ts @@ -4,8 +4,7 @@ import { mergeProps, splitProps } from 'solid-js'; import { createComponent } from 'solid-js/web'; type ErrorBoundaryProps = { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - fallback: JSX.Element | ((err: any, reset: () => void) => JSX.Element); + fallback: JSX.Element | ((err: unknown, reset: () => void) => JSX.Element); children: JSX.Element; }; @@ -16,8 +15,7 @@ export function withSentryErrorBoundary(ErrorBoundary: Component { const [local, others] = splitProps(props, ['fallback']); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const fallback = (error: any, reset: () => void): JSX.Element => { + const fallback = (error: unknown, reset: () => void): JSX.Element => { captureException(error); const f = local.fallback; From 2a1f3f77611f7b4b9b69ffaf0d3f62affc290a48 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 3 Dec 2024 10:16:25 +0100 Subject: [PATCH 2/4] fix it --- packages/replay-internal/src/util/throttle.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/replay-internal/src/util/throttle.ts b/packages/replay-internal/src/util/throttle.ts index ef0a119d7468..66ce6ed0cdfb 100644 --- a/packages/replay-internal/src/util/throttle.ts +++ b/packages/replay-internal/src/util/throttle.ts @@ -10,7 +10,7 @@ export const SKIPPED = '__SKIPPED'; * or else the return value of the original function. */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -export function throttle any>( +export function throttle any>( fn: T, maxCount: number, durationSeconds: number, From d615fb3914665526bc899ded1dacdc608d40103a Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 3 Dec 2024 15:54:30 +0100 Subject: [PATCH 3/4] revert error boundary --- packages/solid/src/errorboundary.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/solid/src/errorboundary.ts b/packages/solid/src/errorboundary.ts index f2600313a723..df75f9da80f9 100644 --- a/packages/solid/src/errorboundary.ts +++ b/packages/solid/src/errorboundary.ts @@ -4,7 +4,8 @@ import { mergeProps, splitProps } from 'solid-js'; import { createComponent } from 'solid-js/web'; type ErrorBoundaryProps = { - fallback: JSX.Element | ((err: unknown, reset: () => void) => JSX.Element); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + fallback: JSX.Element | ((err: any, reset: () => void) => JSX.Element); children: JSX.Element; }; From 11bcde2de039b0e28b34843af69de516842c2a62 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Thu, 5 Dec 2024 14:28:42 +0100 Subject: [PATCH 4/4] fix comments --- packages/core/src/utils-hoist/instrument/globalError.ts | 2 +- .../core/src/utils-hoist/instrument/globalUnhandledRejection.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/utils-hoist/instrument/globalError.ts b/packages/core/src/utils-hoist/instrument/globalError.ts index f864a863121e..bebb301b18d6 100644 --- a/packages/core/src/utils-hoist/instrument/globalError.ts +++ b/packages/core/src/utils-hoist/instrument/globalError.ts @@ -20,7 +20,7 @@ export function addGlobalErrorInstrumentationHandler(handler: (data: HandlerData function instrumentError(): void { _oldOnErrorHandler = GLOBAL_OBJ.onerror; - // Note: The reason we are doing window.onerror instead of window.addEventListener('error') is + // Note: The reason we are doing window.onerror instead of window.addEventListener('error') // is that we are using this handler in the Loader Script, to handle buffered errors consistently GLOBAL_OBJ.onerror = function ( msg: string | object, diff --git a/packages/core/src/utils-hoist/instrument/globalUnhandledRejection.ts b/packages/core/src/utils-hoist/instrument/globalUnhandledRejection.ts index a81d9ba3c780..4b4173233a43 100644 --- a/packages/core/src/utils-hoist/instrument/globalUnhandledRejection.ts +++ b/packages/core/src/utils-hoist/instrument/globalUnhandledRejection.ts @@ -21,7 +21,7 @@ export function addGlobalUnhandledRejectionInstrumentationHandler( function instrumentUnhandledRejection(): void { _oldOnUnhandledRejectionHandler = GLOBAL_OBJ.onunhandledrejection; - // Note: The reason we are doing window.onerror instead of window.addEventListener('unhandledrejection') is + // Note: The reason we are doing window.onunhandledrejection instead of window.addEventListener('unhandledrejection') // is that we are using this handler in the Loader Script, to handle buffered rejections consistently GLOBAL_OBJ.onunhandledrejection = function (e: unknown): boolean { const handlerData: HandlerDataUnhandledRejection = e;