Finally Doesn't Transform Values
You'll learn that .finally() always passes through the original promise's settled value or rejection, no matter what you return inside it.
The Core Behavior
Unlike .then() and .catch(), which can transform promise values by returning something new, .finally() is completely transparent. Whatever the promise resolved or rejected with before .finally() is exactly what comes out after .finally().
Think of .finally() as a glass window: you can look through it and see everything on the other side, but you can't change what's on the other side. The window is just... there.
What Happens to Return Values?
Even if you explicitly return a value inside .finally(), that return value is ignored (unless it's a rejected promise). The original settled value passes through unchanged:
Promise.resolve(42)
.finally(() => {
return 999; // This is ignored!
})
.then(value => {
console.log(value); // 42 (original value)
});
Promise.reject('error')
.finally(() => {
return 'all good'; // This is ignored!
})
.catch(err => {
console.log(err); // 'error' (original rejection)
});
The One Exception
If you return a rejected promise or throw an error inside .finally(), that new error will replace the original outcome. This makes sense — you're introducing a new failure during cleanup.
Key Takeaway: .finally() is a pass-through handler that preserves the original promise's resolved value or rejection reason, making it perfect for cleanup operations that shouldn't affect the promise chain's outcome.