diff --git a/packages/utils/src/promisebuffer.ts b/packages/utils/src/promisebuffer.ts index 033c40d18c51..5ba47670a5c6 100644 --- a/packages/utils/src/promisebuffer.ts +++ b/packages/utils/src/promisebuffer.ts @@ -1,9 +1,6 @@ import { SentryError } from './error'; -import { isThenable } from './is'; import { SyncPromise } from './syncpromise'; -type TaskProducer = () => PromiseLike; - /** A simple queue that holds promises. */ export class PromiseBuffer { /** Internal set of queued Promises */ @@ -21,22 +18,14 @@ export class PromiseBuffer { /** * Add a promise to the queue. * - * @param taskProducer A function producing any PromiseLike; In previous versions this used to be `@param task: PromiseLike`, however, Promises were instantly created on the call-site, making them fall through the buffer limit. + * @param taskProducer A function producing any PromiseLike. * @returns The original promise. */ - public add(taskProducer: PromiseLike | TaskProducer): PromiseLike { - // NOTE: This is necessary to preserve backwards compatibility - // It should accept _only_ `TaskProducer` but we dont want to break other custom transports - // that are utilizing our `Buffer` implementation. - // see: https://github.com/getsentry/sentry-javascript/issues/3725 - const normalizedTaskProducer: TaskProducer = isThenable(taskProducer) - ? () => taskProducer as PromiseLike - : (taskProducer as TaskProducer); - + public add(taskProducer: () => PromiseLike): PromiseLike { if (!this.isReady()) { return SyncPromise.reject(new SentryError('Not adding Promise due to buffer limit reached.')); } - const task = normalizedTaskProducer(); + const task = taskProducer(); if (this._buffer.indexOf(task) === -1) { this._buffer.push(task); }