MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / drainJobs

Function drainJobs

packages/kernel/runtime-quickjs/src/index.ts:298–316  ·  view source on GitHub ↗
(
  context: QuickJSContext,
  runtime: QuickJSRuntime,
  deadlineMs: number,
  timeoutMs: number,
)

Source from the content-addressed store, hash-verified

296 });
297
298const drainJobs = (
299 context: QuickJSContext,
300 runtime: QuickJSRuntime,
301 deadlineMs: number,
302 timeoutMs: number,
303): void => {
304 while (runtime.hasPendingJob()) {
305 if (Date.now() >= deadlineMs) {
306 throw new Error(timeoutMessage(timeoutMs));
307 }
308
309 const pending = runtime.executePendingJobs();
310 if (pending.error) {
311 const error = context.dump(pending.error);
312 pending.error.dispose();
313 throw toError(error);
314 }
315 }
316};
317
318const waitForDeferreds = async (
319 pendingDeferreds: ReadonlySet<QuickJSDeferredPromise>,

Callers 1

drainAsyncFunction · 0.85

Calls 3

timeoutMessageFunction · 0.85
disposeMethod · 0.80
toErrorFunction · 0.70

Tested by

no test coverage detected