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

Function waitAllThrowIfTerminates

src/test/debug_helpers.ts:128–144  ·  view source on GitHub ↗
(dc: DartDebugClient, ...promises: Array<Promise<any>>)

Source from the content-addressed store, hash-verified

126
127/// Waits for all the provided promises, but throws if the debugger terminates before they complete.
128export function waitAllThrowIfTerminates(dc: DartDebugClient, ...promises: Array<Promise<any>>) {
129 let didCompleteSuccessfully = false;
130 return Promise.race([
131 new Promise<void>(async (resolve, reject) => {
132 await dc.waitForEvent("terminated", "waitAllThrowIfTerminates", 180000);
133 // Wait a small amount to allow other awaited tasks to complete.
134 setTimeout(() => {
135 if (didCompleteSuccessfully) {
136 resolve();
137 return;
138 }
139 reject(Error("Terminated while waiting for other promises!"));
140 }, 500);
141 }),
142 Promise.all(promises).then(() => didCompleteSuccessfully = true),
143 ]);
144}
145
146export function ensureVariable(variables: DebugProtocol.Variable[], evaluateName: string | undefined, name: string, value: string | { starts?: string, ends?: string }) {
147 assert.ok(variables?.length, "No variables given to search");

Calls 1

waitForEventMethod · 0.80

Tested by 4

runTestsFunction · 0.72
runWithoutDebuggingFunction · 0.72
testBreakpointConditionFunction · 0.72
testBreakpointConditionFunction · 0.72