找出商品更新里的 bug

来自 HTTP API 设计
Node 24 进阶 4分钟 找出 1处问题

找出这段生成的商品更新代码中的并发缺陷。

JavaScript
async function updateProduct(id, patch, db) {
  const current = await db.products.find(id);
  if (!current) return { status: 404 };
  const updated = { ...current, ...patch };
  await db.products.update(id, updated);
  return { status: 200, body: updated };
}
在试验场中打开
报告错误