Skip to content

Async

The gap inside an await

Checking a condition and acting on it, with a suspension point in between. The cache that fills twice.

14 minutes · TOCTOU · cache stampede · in-flight deduplication

Every await is a gap

An `await` gives up the turn. Anything else that was waiting gets to run, and it can change any state your function was about to rely on. The pattern that gets people is a check, then a suspension, then an action that assumed the check still holds.

It reads perfectly. It passes review. It passes tests, because reproducing it needs a second request to arrive inside a window measured in microseconds — which is exactly what happens the first time the service is under real load.

Everything you do here stays in this browser.