Code Room
Code reviewHard
Question
Review this Node consumer that processes payment events from an at-least-once queue.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
async function handle(msg) { const { paymentId, amount, userId } = JSON.parse(msg.body); await db.query( "UPDATE accounts SET balance = balance + $1 WHERE id = $2", [amount, userId] ); await ledger.insert({ paymentId, amount, userId }); await msg.ack();}Run or narrate your approach, then ask the coach.