Skip to main content

Editable promises - advanced

Promise.race vs Promise.any

Switch methods and result patterns to see why first does not always mean first success.

partially simulatedcurated scenariodoes not execute real code
Short answer

Promise.race uses the first settled promise.

Real-world bug this helps solve

Fallback APIs, CDN mirrors, timeout races, and redundant request strategies.

Common wrong assumption

Using race when you actually want the first successful result.

Fix direction

Using race when you actually want the first successful result.

Fixed code pattern
// Change the safe controls, then compare the generated fixed behavior.
Visual proof

Change the controls and watch the generated timeline reset so the changed behavior is visible.

How to verify in a real app

Reproduce the small case, apply the safer pattern, and verify output, timing, or memory before and after the change.

Share
Loading editable case...

Related cases

Continue with nearby confusion while the mental model is fresh.

Recommended next

Was this clear?

This stays local for now. It helps you track where the product still needs sharper cases.

Send detail