settle
Run pending microtasks and timer callbacks until the queue is empty, subject to maximum time and iteration limits. Use after executing code that schedules asynchronous work to allow all pending callbacks to complete.
Instructions
Drain the JS event loop: alternately runs queued microtasks (Promise resolutions) and fires expired setTimeout/setInterval callbacks, sleeping to the next deadline when only timers remain. Returns when the queue is empty OR max_ms elapses OR max_iters iterations complete. Defaults: max_ms=2000, max_iters=50. Use after seeding the DOM (or after eval'd code that schedules timers) to let pending callbacks run.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| max_ms | No | Max wall-clock ms to spend (default 2000) | |
| max_iters | No | Max iterations of the drain loop (default 50) |