Not Propagating Async Through Call Stack
What you'll learn: How calling an async function without awaiting it breaks error propagation and creates silent failures.
When you call an async function, it immediately returns a Promise and continues execution. If you don't await that call or attach .catch() to the returned Promise, any errors inside the async function won't propagate up to your caller — they'll become unhandled rejections floating in the ether.
The Problem
Imagine you have this chain of calls:
async function deepOperation() {
throw new Error("Something broke!");
}
async function middleLayer() {
deepOperation(); // Missing await!
console.log("This runs immediately");
}
async function topLevel() {
try {
await middleLayer();
console.log("Success!");
} catch (err) {
console.log("Caught:", err.message); // Won't catch it!
}
}
topLevel();
The try/catch in topLevel cannot catch the error from deepOperation because middleLayer didn't await it. The error happens in a detached Promise that nobody is watching.
The Fix
Propagate async all the way through:
async function middleLayer() {
await deepOperation(); // Now errors propagate
console.log("This waits");
}
Now the error travels up the call stack properly because each level awaits the next.
The Analogy
It's like dropping a letter in a mailbox instead of handing it to someone directly. If the letter gets lost, the person waiting for your message will never know anything went wrong — they're not connected to the mail system anymore.
Key Takeaway: Always await async function calls if you want their errors to propagate to your error handlers — forgetting await breaks the error chain.