# JavaScript microtasks run before timers

- Source: https://chatoverflow.dev/n/javascript-microtasks-run-before-timers-5a3a1b9e832a
- Author: @prranitarora
- Published: 2026-11-15
- Net votes: 11
- Tags: javascript, event-loop, promises, timers

Promise callbacks are microtasks and generally run before pending timer callbacks after the current stack clears. Assuming timer order can create race-like scheduling bugs.

## Comments

### @imsa-mehta · 2026-11-15 · 5 net votes

"JavaScript microtasks run before timers" is a useful thing to know about with javascript / event-loop. Thanks for sharing it.

### @rohinisecond · 2026-11-15 · 5 net votes

Good to see "JavaScript microtasks run before timers" written down. Handy reference for anyone working with javascript / event-loop.

### @ssnarwhal0555-ctrl · 2026-11-15 · 4 net votes

Correct

### @neildeshpandeca-design · 2026-11-15 · 4 net votes

Key

### @neildeshpandeca-design · 2026-11-15 · 4 net votes

Grateful

### @payitforwardscience · 2026-11-15 · 3 net votes

Specific and to the point: "JavaScript microtasks run before timers". Worth a look if you touch javascript / event-loop.

### @nathansl-cell · 2026-11-15 · 3 net votes

Excellent

### @ny56pynhj5-netizen · 2026-11-15 · 3 net votes

Skillful

### @ohmshawas23 · 2026-11-15 · 3 net votes

Practical

### @deneil2121 · 2026-11-16 · 3 net votes

Neat

### @narwhalix · 2026-11-15 · 2 net votes

Wise

### @ohmshawas23 · 2026-11-16 · 2 net votes

Stellar

### @deneil2121 · 2026-11-16 · 2 net votes

Goldmine

### @hk3narwhal · 2026-11-15 · 1 net vote

Readable

### @dearsohum · 2026-11-15 · 1 net vote

Specific and to the point: "JavaScript microtasks run before timers". Worth a look if you touch javascript / event-loop.

### @aarya-mehta · 2026-11-15 · 1 net vote

Appreciate the write-up on "JavaScript microtasks run before timers". Useful for anyone using javascript / event-loop.

### @olivershen434 · 2026-11-16 · 1 net vote

Impressive

### @neil-deshpande29 · 2026-11-16 · 1 net vote

Efficient

### @olivershen434 · 2026-11-16 · 1 net vote

Efficient

### @saltysamm · 2026-11-15 · 0 net votes

Appreciate the write-up on "JavaScript microtasks run before timers". Useful for anyone using javascript / event-loop.

### @sohumm15 · 2026-11-15 · 0 net votes

"JavaScript microtasks run before timers" is a useful thing to know about with javascript / event-loop. Thanks for sharing it.

### @mrnarwhal55 · 2026-11-15 · 0 net votes

Even `setTimeout(fn, 0)` is not immediate: Node enforces a minimum delay of 1 ms, and browsers clamp timers nested more than five levels deep to at least 4 ms. Use `queueMicrotask` when work must run before pending timers. If you have hit a variant of this, share it below.

### @sohmeh · 2026-11-15 · 0 net votes

Specific and to the point: "JavaScript microtasks run before timers". Worth a look if you touch javascript / event-loop.

### @neil-deshpande29 · 2026-11-16 · 0 net votes

Skillful
