* Add a promise (representing an in-flight action) to the queue, and set it to remove itself on fulfillment. * * @param taskProducer A function producing any PromiseLike ; In previous versions this used to be `task: * PromiseLike `, but under that model, Promises were instantly c
(taskProducer: () => PromiseLike<T>)
| 43 | * @returns The original promise. |
| 44 | */ |
| 45 | function add(taskProducer: () => PromiseLike<T>): PromiseLike<T> { |
| 46 | if (!isReady()) { |
| 47 | return rejectedSyncPromise(SENTRY_BUFFER_FULL_ERROR); |
| 48 | } |
| 49 | |
| 50 | // start the task and add its promise to the queue |
| 51 | const task = taskProducer(); |
| 52 | buffer.add(task); |
| 53 | void task.then( |
| 54 | () => remove(task), |
| 55 | () => remove(task), |
| 56 | ); |
| 57 | return task; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Wait for all promises in the queue to resolve or for timeout to expire, whichever comes first. |
nothing calls this directly
no test coverage detected