Code Room
Code reviewMediumcr-g316
Subject Swallowed exceptionsLevel Mid–Senior~18 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this JavaScript request handler that returns immediately and does the slow reindex work in the background.

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 reindex(docId) {  const doc = await store.fetch(docId);      // may reject  await searchClient.index(doc);             // may reject / time out} app.post("/reindex", (req, res) => {  const { docId } = req.body;  if (!docId) {    return res.status(400).json({ error: "docId required" });  }  res.status(202).json({ status: "queued" });  reindex(docId).then(() => {    metrics.inc("reindex.ok");  });});
Run or narrate your approach, then ask the coach.