Promise.all vs allSettled vs race vs any — Free Interactive Visualizer

Promise.all vs allSettled vs race vs any Visualizer · Visualizers · Plain HTML, CSS & JS · Live preview

CategoryVisualizers

What's included

Features

Real promises
Actual resolve/reject timers, not a simulation of the rules.
All four combinators
all, allSettled, race and any side by side.
Live timeline
Bars grow with elapsed time.
Settle markers
Amber for fulfilled, red for rejected.
Ignored tasks faded
Work that can no longer affect the result.
Result values shown
Arrays, statuses and AggregateError.
Configurable tasks
Duration and failure per task.
No unhandled rejections
Raw promises are caught explicitly.

About this UI Snippet

JavaScript Promise Combinators — Four Rules on One Timeline

Screenshot of the Promise.all vs allSettled vs race vs any Visualizer snippet rendered live

JavaScript has four built-in ways to wait for several promises at once, and they differ in exactly two things: when they settle, and what counts as success. Reading the spec wording is one thing; seeing the same four tasks produce four different outcomes is what makes it stick.

Real promises, same start time

Each task is a real Promise that resolves or rejects after its delay. All four combinators receive the same array of promises at the same moment, so the only difference between lanes is the combinator's rule.

The four rules

- Promise.all fulfils with an array of values when every task fulfils, and rejects immediately when any task rejects — it short-circuits on the first failure. - Promise.allSettled never rejects. It waits for every task and fulfils with { status, value | reason } objects. - Promise.race settles the same way as whichever task settles first, success or failure. - Promise.any fulfils with the first success and ignores failures, rejecting with an AggregateError only if every task fails.

Reading the timeline

Bars grow in real time. Striped bars are rejections. The vertical line marks when the combinator settled — amber for fulfilled, red for rejected — and bars that are still running afterwards fade, because nothing they do can change that combinator's result.

Short-circuiting doesn't cancel

When Promise.all rejects early, the other tasks keep running: promises have no built-in cancellation. The faded bars keep growing to make this visible. Use an AbortController to actually stop network requests.

Unhandled rejections

The raw task promises get an empty .catch() so the browser doesn't report unhandled rejections for promises that are observed only through combinators.

Build with AI

Build, Understand, Optimize, and Extend It With AI

Paste this visualizer into an AI assistant like Claude and ask it to predict each lane's result for a given configuration, then check with Run. Ask it to add AbortController so that Promise.all's early rejection actually cancels the other tasks, a fifth lane for a custom "first N succeed" combinator, or a timeout lane built with Promise.race. It can also explain how microtasks affect the exact order of the settle callbacks.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build an interactive visualizer comparing Promise.all, Promise.allSettled, Promise.race and Promise.any in plain HTML, CSS and JavaScript on a dark theme.

Requirements:
- Four configurable tasks, each with a name, a duration slider (100–2000 ms) and a "Rejects" checkbox.
- Each run creates four real promises that resolve or reject after their durations, and passes the same array to all four combinators at the same moment; attach an empty catch to the raw promises to avoid unhandled rejections.
- One lane per combinator with its rule in one sentence, a timeline where each task's bar grows in real time (striped when it rejects), and a vertical marker at the moment the combinator settled (amber if fulfilled, red if rejected).
- Fade the bars of tasks that finish after a combinator has settled, since they can't affect its result.
- Print each combinator's outcome and value, including allSettled's status list and any's AggregateError.
- A Randomise button for durations and failures, and an automatic first run.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.

Source Code

<div class="pc">
  <div class="pc-top">
    <h2>Promise combinators on a timeline</h2>
    <p>Set how long each task takes and whether it fails, then run all four combinators on the same tasks at the same moment.</p>
  </div>
  <div class="pc-tasks" id="pcTasks"></div>
  <div class="pc-actions">
    <button type="button" id="pcRun">Run all four</button>
    <button type="button" id="pcPreset" class="ghost">Randomise</button>
  </div>
  <div class="pc-lanes" id="pcLanes"></div>
</div>

Step by step

How to Use

  1. 1
    Watch the first runThe page runs once automatically with a failing third task.
  2. 2
    Adjust tasksChange each task's duration and tick "Rejects" to make it fail.
  3. 3
    Run all fourCompare when and how each combinator settles.
  4. 4
    RandomiseGenerate new durations and failures to test your predictions.
  5. 5
    Predict firstGuess each lane's result before pressing Run.

Real-world uses

Common Use Cases

Learning async JavaScript
The clearest comparison of the four combinators.
Choosing the right API
Load a dashboard's widgets with allSettled, not all.
Timeouts
See why race is used to add a timeout to a request.
Fallback mirrors
any returns the first mirror that responds.
Teaching and interviews
A frequently asked JavaScript question.
Related: Event Loop Visualizer
When promise callbacks actually run: Event Loop Visualizer.
Related: Debounce vs Throttle
Another timing concept visualized: Debounce vs Throttle Visualizer.

Got questions?

Frequently Asked Questions

Promise.all rejects as soon as any promise rejects, so you lose the other results. Promise.allSettled waits for every promise and always fulfils with an array of { status, value } or { status, reason } objects.

race settles with the first promise to settle, even if it rejects. any waits for the first promise to fulfil and ignores rejections, rejecting with an AggregateError only if all of them reject.

No. JavaScript promises cannot be cancelled. The other operations keep running; only the combined promise has already rejected. Use AbortController to cancel fetch requests.

Race the request against a promise that rejects after a delay: Promise.race([fetch(url), timeout(5000)]). Better still, use AbortSignal.timeout(5000) so the request is actually aborted.

When the tasks are independent and a failure in one shouldn't discard the others, such as loading several dashboard widgets or sending a batch of notifications.