No Login Data Private Local Save

Promise State Viewer - Online Check Resolve & Reject

17
0
0
0

Promise State Viewer

Inspect, visualize & interact with JavaScript Promise states in real-time

Pending Fulfilled Rejected
Live Promise Inspector
PENDING
Awaiting settlement...
Elapsed: 0.0s
0ms 5000ms
This Promise has been settled. Click Reset to try again.
State History
No history yet.
Create a Promise and settle it!
Equivalent Code
const promise = new Promise((resolve, reject) => { // Promise is currently PENDING // Waiting to be settled... });
Quick Scenarios — Click to Load
Fast Resolve
500ms ¡ Instant success
Slow Rejection
3000ms ¡ Delayed error
API Call Sim
2000ms ¡ Mock fetch
Manual Control
You decide the fate
Promise States — FAQ & Knowledge

A JavaScript Promise has exactly three mutually exclusive states:
  • Pending — Initial state; the operation has not completed yet.
  • Fulfilled — The operation completed successfully, and the Promise has a resolved value.
  • Rejected — The operation failed, and the Promise has a reason (error) for the failure.
Once a Promise transitions from pending to either fulfilled or rejected, it becomes settled and can never change state again.

No. Once a Promise is settled (fulfilled or rejected), its state is immutable. Any subsequent calls to resolve() or reject() are silently ignored. This guarantees that .then() and .catch() handlers are invoked at most once, making Promise behavior predictable and race-condition-free.

JavaScript does not expose a direct synchronous API to query a Promise's state. However, you can use Promise.race() with a special sentinel value, or maintain a wrapper that tracks the state manually (as this tool does). In production, consider using state machines or libraries like p-state for explicit state inspection.

Fulfilled is a state — the Promise completed successfully. Resolved refers to the action of calling resolve(). However, if resolve() is called with another Promise, the original Promise follows that inner Promise — it hasn't fulfilled yet. So a Promise can be resolved but still pending if it's waiting for another Promise to settle.

async/await is syntactic sugar over Promises, making asynchronous code look synchronous and easier to read. Use Promises directly when you need fine-grained control (e.g., Promise.all, Promise.race, custom promise chains). Use async/await for cleaner sequential logic. They are fully interoperable — an async function always returns a Promise.

  • Unhandled rejections — Always add a .catch() or use try/catch with await.
  • Forgetting to return in .then() chains — breaks the chain.
  • Promise constructor anti-pattern — Wrapping an already-returned Promise in new Promise().
  • Mixing sync and async without understanding the microtask queue order.
  • Not handling partial failures in Promise.all() — use Promise.allSettled() instead.

When resolve(promiseB) is called inside promiseA, promiseA adopts the state of promiseB. It remains pending until promiseB settles, then fulfills or rejects with the same value or reason. This is called promise assimilation or unwrapping, and it's a core mechanism enabling Promise chaining.