MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / disposeAllAsync

Function disposeAllAsync

src/shared/utils.ts:250–270  ·  view source on GitHub ↗
(disposables: IAmDisposableAsync[], logger?: Logger)

Source from the content-addressed store, hash-verified

248 * within 3s.
249 */
250export async function disposeAllAsync(disposables: IAmDisposableAsync[], logger?: Logger): Promise<void> {
251 const toDispose = disposables.slice();
252 disposables.length = 0;
253 try {
254 await withTimeout(
255 Promise.allSettled(toDispose.map(async (d) => {
256 try {
257 await d.dispose();
258 } catch (e: any) {
259 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
260 logger?.error({ message: e.toString() });
261 console.warn(e);
262 }
263 })),
264 "disposeAllAsync did not complete",
265 3,
266 );
267 } catch (e) {
268 console.warn(e);
269 }
270}
271
272export async function withTimeout<T>(promise: Thenable<T>, message: string | (() => string), seconds = 360): Promise<T> {
273 return new Promise<T>((resolve, reject) => {

Callers 3

disposeFunction · 0.90
disposeFunction · 0.90
activateFunction · 0.90

Calls 5

withTimeoutFunction · 0.70
disposeMethod · 0.65
errorMethod · 0.65
warnMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected