Event Loop and Source Panels
Promise Then Chain
Trace ordered Promise callbacks as a single-thread event-loop sequence.
Promise Then Chain
promise_then_chain.js
const base = 6;
let first = 0;
let second = 0;
function addStep(value) {
first = value + 4;
return first;
}
function finishStep(value) {
second = value * 2;
console.log("base=" + base);
console.log("first=" + first);
console.log("second=" + second);
}
Promise.resolve(base)
.then(addStep)
.then(finishStep);
promise-chain
A Promise chain runs callbacks later, but still in a deterministic order. Replay shows each callback updating the same source panel.