MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / add

Function add

packages/core/src/utils/promisebuffer.ts:45–58  ·  view source on GitHub ↗

* 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>)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 5

rejectedSyncPromiseFunction · 0.90
isReadyFunction · 0.85
removeFunction · 0.70
addMethod · 0.65
thenMethod · 0.45

Tested by

no test coverage detected