Code Room
Code reviewMedium
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.
Learn the concepts
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.