Async & Promises
Code Review: Async Error Handling
mediumCode ReviewJS / TS
Problem Statement
Review the following payment notification pipeline. Identify problematic async behavior, missing error handling, floating unawaited promises, and failure propagation issues.
Code under review
JAVASCRIPT• handler.js
Pairlet Snippet
// Background job processing webhook notifications
async function processWebhookPayment(payload) {
try {
const payment = await verifyPaymentSignature(payload);
auditLogger.logTransaction({ id: payment.id, amount: payment.amount });
payload.items.forEach(async (item) => {
await updateInventoryStock(item.id, item.qty);
await sendReceiptEmail(payment.customerEmail, item);
});
return { status: "processed" };
} catch (err) {
console.log("Something went wrong:", err);
return { status: "processed" };
}
}
Read only. Write down what you would flag below, then compare with the reference notes.
JavaScript & TypeScript versions included
Run this as a live interviewPractice solo
Write down what you would flag in this code, then compare it with the reference notes.
Write your findings first, then check yourself against the notes.