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

Function drainJobs

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

Source from the content-addressed store, hash-verified

306 });
307
308const drainJobs = (
309 context: QuickJSContext,
310 runtime: QuickJSRuntime,
311 deadlineMs: number,
312 timeoutMs: number,
313): void => {
314 while (runtime.hasPendingJob()) {
315 if (Date.now() >= deadlineMs) {
316 throw new Error(timeoutMessage(timeoutMs));
317 }
318
319 const pending = runtime.executePendingJobs();
320 if (pending.error) {
321 const error = context.dump(pending.error);
322 pending.error.dispose();
323 throw toError(error);
324 }
325 }
326};
327
328const waitForDeferreds = async (
329 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