( context: QuickJSContext, runtime: QuickJSRuntime, deadline: DeadlineTracker, timeoutMs: number, )
| 365 | }); |
| 366 | |
| 367 | const drainJobs = ( |
| 368 | context: QuickJSContext, |
| 369 | runtime: QuickJSRuntime, |
| 370 | deadline: DeadlineTracker, |
| 371 | timeoutMs: number, |
| 372 | ): void => { |
| 373 | while (runtime.hasPendingJob()) { |
| 374 | const deadlineMs = deadline.deadlineMs(); |
| 375 | if (deadlineMs !== null && Date.now() >= deadlineMs) { |
| 376 | throw new Error(timeoutMessage(timeoutMs)); |
| 377 | } |
| 378 | |
| 379 | const pending = runtime.executePendingJobs(); |
| 380 | if (pending.error) { |
| 381 | const error = context.dump(pending.error); |
| 382 | pending.error.dispose(); |
| 383 | throw toError(error); |
| 384 | } |
| 385 | } |
| 386 | }; |
| 387 | |
| 388 | const waitForDeferreds = async ( |
| 389 | pendingDeferreds: ReadonlySet<QuickJSDeferredPromise>, |
no test coverage detected