Code Room
Code reviewHardcr-g098
Subject IdempotencyLevel Senior–Staff~30 minCommon in Networking & APIs · Distributed systems · Algorithms & data structures interviewsIndustries Software development

Question

Review this JavaScript SQS-style consumer.

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.

Talk through your review
Code to reviewjs
async function poll() {  const { Messages = [] } = await sqs.receiveMessage({    QueueUrl: ORDER_QUEUE,    MaxNumberOfMessages: 10,    WaitTimeSeconds: 20,  });  for (const msg of Messages) {    await onMessage(msg);  }} async function onMessage(msg) {  const order = JSON.parse(msg.body);  await inventory.decrement(order.sku, order.qty);  await ledger.recordSale(order);  await queue.deleteMessage(msg.receiptHandle);}
Run or narrate your approach, then ask the coach.