Skip to content

Commit 028130d

Browse files
committed
ref: Leave only valid buffer implementation
1 parent 740443d commit 028130d

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

packages/utils/src/promisebuffer.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { SentryError } from './error';
2-
import { isThenable } from './is';
32
import { SyncPromise } from './syncpromise';
43

5-
type TaskProducer<T> = () => PromiseLike<T>;
6-
74
/** A simple queue that holds promises. */
85
export class PromiseBuffer<T> {
96
/** Internal set of queued Promises */
@@ -24,19 +21,11 @@ export class PromiseBuffer<T> {
2421
* @param taskProducer A function producing any PromiseLike<T>; In previous versions this used to be `@param task: PromiseLike<T>`, however, Promises were instantly created on the call-site, making them fall through the buffer limit.
2522
* @returns The original promise.
2623
*/
27-
public add(taskProducer: PromiseLike<T> | TaskProducer<T>): PromiseLike<T> {
28-
// NOTE: This is necessary to preserve backwards compatibility
29-
// It should accept _only_ `TaskProducer<T>` but we dont want to break other custom transports
30-
// that are utilizing our `Buffer` implementation.
31-
// see: https://github.com/getsentry/sentry-javascript/issues/3725
32-
const normalizedTaskProducer: TaskProducer<T> = isThenable(taskProducer)
33-
? () => taskProducer as PromiseLike<T>
34-
: (taskProducer as TaskProducer<T>);
35-
24+
public add(taskProducer: () => PromiseLike<T>): PromiseLike<T> {
3625
if (!this.isReady()) {
3726
return SyncPromise.reject(new SentryError('Not adding Promise due to buffer limit reached.'));
3827
}
39-
const task = normalizedTaskProducer();
28+
const task = taskProducer();
4029
if (this._buffer.indexOf(task) === -1) {
4130
this._buffer.push(task);
4231
}

0 commit comments

Comments
 (0)