Pattern: return
statement in Promise.finally()
Issue: -
Using a return
statement inside a finally()
callback is ineffective since the returned value will not be consumed. The finally()
block should only be used for cleanup code that needs to run regardless of the promise outcome.
Example of incorrect code:
myPromise.finally(function (val) {
return val;
});
Example of correct code:
Promise.resolve(1).finally(() => {
console.log(2);
});