function
jsc.drainMicrotasks
Runs every pending microtask right now: promise reactions, queueMicrotask() callbacks, and process.nextTick() callbacks. Callbacks that Bun's event loop has already queued, such as those of I/O that has completed, run as well. Nothing is waited for, and timers do not fire.
Microtasks normally run only after the current script or callback finishes; this lets synchronous code observe their effects immediately.
import { drainMicrotasks } from "bun:jsc";
let resolved = false;
Promise.resolve().then(() => {
resolved = true;
});
drainMicrotasks();
resolved; // true