[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-trigger-dev-staff-engineering-skills-idempotency":3,"mdc-ttecq2-key":31,"related-org-trigger-dev-staff-engineering-skills-idempotency":4978,"related-repo-trigger-dev-staff-engineering-skills-idempotency":5146},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":12,"stars":20,"repoUrl":21,"updatedAt":22,"license":23,"forks":24,"topics":25,"repo":26,"sourceUrl":29,"mdContent":30},"staff-engineering-skills-idempotency","ensure idempotency for retriable operations","Ensure operations are safe to retry and execute multiple times. Use when writing API endpoints that mutate state, webhook handlers, queue consumers, payment processing, retry logic, or any code that creates records, sends emails, charges cards, or increments counters. Activates on patterns like POST handlers without deduplication, retry wrappers around non-idempotent calls, webhook processors, or queue message handlers.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},"trigger-dev","Trigger.dev","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Ftrigger-dev.jpg","triggerdotdev",[13,17],{"name":14,"slug":15,"type":16},"Architecture","architecture","tag",{"name":18,"slug":19,"type":16},"API Development","api-development",3,"https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Fstaff-engineering-skills","2026-06-17T08:40:41.489972",null,1,[],{"repoUrl":21,"stars":20,"forks":24,"topics":27,"description":28},[],"Skills that give AI   coding agents staff-engineer instincts: recognizing and avoiding production failure modes like cardinality, idempotency, and race conditions.","https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Fstaff-engineering-skills\u002Ftree\u002FHEAD\u002Fskills\u002Fstaff-engineering-skills-idempotency","---\nname: staff-engineering-skills-idempotency\ndescription: Ensure operations are safe to retry and execute multiple times. Use when writing API endpoints that mutate state, webhook handlers, queue consumers, payment processing, retry logic, or any code that creates records, sends emails, charges cards, or increments counters. Activates on patterns like POST handlers without deduplication, retry wrappers around non-idempotent calls, webhook processors, or queue message handlers.\n---\n\n# Idempotency Trap\n\nThe request was sent twice. The customer was charged twice. Before writing any operation that mutates state, ask: **what happens if this runs again with the same input?**\n\n## The Three Sources of Duplicates\n\nEvery system faces these as normal operation, not edge cases. You cannot prevent them -- only make operations safe when they happen.\n\n1. **User retries** -- double-click, refresh, back-button-and-resubmit. Client sends the same request twice intentionally.\n2. **Network retries** -- the operation succeeded but the response was lost (timeout, TCP reset, LB cut). Client retries, not knowing the first attempt worked.\n3. **Infrastructure redelivery** -- webhook providers retry on timeout, message queues deliver \"at least once,\" cron jobs overlap. Infrastructure sends the same work twice.\n\n## Naturally Idempotent vs Not\n\n| Naturally idempotent (safe to repeat) | NOT idempotent (dangerous to repeat) |\n|---------------------------------------|--------------------------------------|\n| `SET x = 5` | `SET x = x + 1` |\n| `UPDATE status = 'paid' WHERE id = ?` | `INSERT INTO orders (...)` |\n| `DELETE WHERE id = ?` | `balance += amount` |\n| `PUT \u002Fusers\u002F123 {full body}` | `POST \u002Forders {new order}` |\n| Upsert (INSERT ... ON CONFLICT UPDATE) | `sendEmail(user, template)` |\n| | `stripe.charges.create(...)` |\n\n**Design for natural idempotency first.** If you can express the operation as \"set to this state\" rather than \"apply this change,\" it's inherently safe.\n\n## Detection: Non-Idempotent Code\n\n**Stop and add idempotency protection if you see:**\n\n1. **A POST handler that creates a record without an idempotency key** -- double-submit creates duplicates.\n2. **Retry logic wrapping a non-idempotent call** -- retrying `stripe.charges.create()` without an idempotency key double-charges; retrying `POST \u002Forders` creates duplicates.\n3. **A webhook handler that doesn't record processed event IDs** -- Stripe, GitHub, Twilio all document that they may resend the same event.\n4. **A queue consumer that uses `INCREMENT` or `INSERT` without deduplication** -- SQS, RabbitMQ, Kafka (at-least-once) can all deliver the same message twice.\n5. **`sendEmail()`, `sendSMS()`, or any notification call without a dedup check** -- the user gets two of everything.\n6. **Multi-step operations where early steps have side effects** -- if step 3 fails and the client retries, steps 1 and 2 run again. Are they safe to repeat?\n\n## Patterns\n\n### Idempotency key (for API endpoints)\n\nThe client generates a unique key (UUID) and sends it with the request; the server detects retries by the key.\n\n```typescript\napp.post(\"\u002Fapi\u002Forders\", async (req, res) => {\n  const idempotencyKey = req.headers[\"idempotency-key\"];\n  if (!idempotencyKey) {\n    return res.status(400).json({ error: \"Idempotency-Key header required\" });\n  }\n\n  \u002F\u002F Return stored response if already processed\n  const existing = await db.idempotencyRecord.findUnique({ where: { key: idempotencyKey } });\n  if (existing?.status === \"complete\") {\n    return res.status(existing.statusCode).json(existing.responseBody);\n  }\n\n  \u002F\u002F Claim key + create business data in ONE transaction (unique constraint loses the race for one of two retries)\n  const order = await db.$transaction(async (tx) => {\n    await tx.idempotencyRecord.create({ data: { key: idempotencyKey, status: \"processing\" } });\n    return tx.order.create({\n      data: { userId: req.user.id, items: req.body.items, total: req.body.total },\n    });\n  });\n\n  \u002F\u002F External side effects get THEIR OWN key derived from the original\n  await stripe.paymentIntents.create(\n    { customer: req.user.id, amount: order.total, currency: \"usd\" },\n    { idempotencyKey: `charge-${idempotencyKey}` }\n  );\n\n  \u002F\u002F Store response so duplicates get the SAME response as the original\n  await db.idempotencyRecord.update({\n    where: { key: idempotencyKey },\n    data: { status: \"complete\", statusCode: 201, responseBody: order },\n  });\n\n  res.status(201).json(order);\n});\n```\n\nThe three load-bearing details: the idempotency record is created in the **same transaction** as the business data; external APIs get **their own** keys derived from the original; the stored response is replayed on duplicates.\n\n### Webhook deduplication (for incoming webhooks)\n\nWebhook providers include a unique event ID. Record it and skip duplicates. The unique constraint on `eventId` also catches races between two simultaneous deliveries. Non-transactional side effects (emails) go **after** the dedup gate.\n\n```typescript\napp.post(\"\u002Fwebhooks\u002Fstripe\", async (req, res) => {\n  const event = req.body;\n\n  try {\n    await db.$transaction(async (tx) => {\n      await tx.processedWebhookEvent.create({ data: { eventId: event.id, processedAt: new Date() } });\n      if (event.type === \"payment_intent.succeeded\") {\n        await tx.order.update({\n          where: { paymentIntentId: event.data.object.id },\n          data: { status: \"paid\" },\n        });\n      }\n    });\n  } catch (error) {\n    if (isPrismaUniqueConstraintError(error)) {\n      return res.json({ received: true }); \u002F\u002F Already processed, skip\n    }\n    throw error;\n  }\n\n  if (event.type === \"payment_intent.succeeded\") {\n    await sendConfirmationEmail(event.data.object.metadata.userId);\n  }\n  res.json({ received: true });\n});\n```\n\n### Queue consumer deduplication\n\nThe producer includes a unique transaction\u002Fmessage ID; the consumer records it in the same transaction as the work. On a real error, **don't ack** -- let the queue redeliver.\n\n```typescript\nworker.on(\"message\", async (msg) => {\n  const { transactionId, userId, amount } = JSON.parse(msg.body);\n\n  try {\n    await db.$transaction(async (tx) => {\n      \u002F\u002F Unique constraint on transactionId prevents duplicates\n      await tx.processedTransaction.create({ data: { id: transactionId, processedAt: new Date() } });\n      await tx.account.update({ where: { userId }, data: { balance: { increment: amount } } });\n    });\n  } catch (error) {\n    if (isPrismaUniqueConstraintError(error)) {\n      await msg.ack(); \u002F\u002F Already processed -- ack and move on\n      return;\n    }\n    throw error; \u002F\u002F Real error -- don't ack, let queue redeliver\n  }\n\n  await msg.ack();\n});\n```\n\n### Natural idempotency via upsert\n\nWhen possible, design the operation so repeating it converges on the same state -- upsert, or SET rather than INCREMENT.\n\n```typescript\n\u002F\u002F Same result whether it runs once or five times\nasync function setUserPreference(userId: string, key: string, value: string) {\n  await db.userPreference.upsert({\n    where: { userId_key: { userId, key } },\n    create: { userId, key, value },\n    update: { value },\n  });\n}\n```\n\n### Making external API calls idempotent\n\nMost payment\u002Fcommunication APIs support idempotency keys -- always pass them.\n\n```typescript\nawait stripe.paymentIntents.create(\n  { customer: customerId, amount, currency: \"usd\" },\n  { idempotencyKey: `order-${orderId}-charge` }\n);\n\u002F\u002F Twilio: unique message SID or your own dedup. SendGrid: custom unique args. AWS SES: MessageDeduplicationId (FIFO).\n```\n\nIf the API has no idempotency-key support, track the call yourself:\n\n```typescript\nasync function sendWelcomeEmail(userId: string) {\n  const sent = await db.sentEmail.findUnique({\n    where: { userId_template: { userId, template: \"welcome\" } },\n  });\n  if (sent) return; \u002F\u002F Already sent\n\n  await emailService.send({ to: userId, template: \"welcome\" });\n  await db.sentEmail.create({ data: { userId, template: \"welcome\", sentAt: new Date() } });\n}\n```\n\n## Anti-Patterns\n\n```typescript\n\u002F\u002F Dangerous: retry wrapping a non-idempotent call\nawait retry(() => stripe.paymentIntents.create({ amount, customer }), { retries: 3 });\n\u002F\u002F First call succeeds, response lost, retry creates a SECOND charge. Fix: pass idempotencyKey to Stripe.\n\n\u002F\u002F Dangerous: POST handler with no dedup -- double-click = two orders, two charges\napp.post(\"\u002Fapi\u002Forders\", async (req, res) => {\n  const order = await db.order.create({ data: req.body });\n  await chargeCustomer(order.total);\n  res.status(201).json(order);\n});\n\u002F\u002F Fix: require and check Idempotency-Key header.\n\n\u002F\u002F Dangerous: queue consumer with INCREMENT -- SQS delivers twice = balance incremented twice\nworker.on(\"message\", async (msg) => {\n  const { userId, amount } = JSON.parse(msg.body);\n  await db.account.update({ where: { userId }, data: { balance: { increment: amount } } });\n  await msg.ack();\n});\n\u002F\u002F Fix: dedup on transactionId in a single transaction.\n```\n\n## Related Traps\n\n- **Race Conditions** -- idempotency checks are themselves vulnerable to races. Two retries arriving simultaneously can both pass the \"already processed?\" check. The dedup record must be created atomically with the business operation (same transaction, unique constraint).\n- **Consistency Models** -- if your dedup check reads from a replica but the dedup record was written to the primary, replica lag can cause the check to miss the duplicate. Dedup checks must read from the primary.\n- **Retry Storms** -- retrying non-idempotent operations doesn't just create duplicates -- it amplifies load. Idempotency + retry storms = data corruption at scale.\n",{"data":32,"body":33},{"name":4,"description":6},{"type":34,"children":35},"root",[36,45,57,64,69,104,110,255,265,271,279,388,394,401,406,1793,1812,1818,1838,2691,2697,2709,3348,3354,3359,3622,3628,3633,3799,3804,4223,4229,4932,4938,4972],{"type":37,"tag":38,"props":39,"children":41},"element","h1",{"id":40},"idempotency-trap",[42],{"type":43,"value":44},"text","Idempotency Trap",{"type":37,"tag":46,"props":47,"children":48},"p",{},[49,51],{"type":43,"value":50},"The request was sent twice. The customer was charged twice. Before writing any operation that mutates state, ask: ",{"type":37,"tag":52,"props":53,"children":54},"strong",{},[55],{"type":43,"value":56},"what happens if this runs again with the same input?",{"type":37,"tag":58,"props":59,"children":61},"h2",{"id":60},"the-three-sources-of-duplicates",[62],{"type":43,"value":63},"The Three Sources of Duplicates",{"type":37,"tag":46,"props":65,"children":66},{},[67],{"type":43,"value":68},"Every system faces these as normal operation, not edge cases. You cannot prevent them -- only make operations safe when they happen.",{"type":37,"tag":70,"props":71,"children":72},"ol",{},[73,84,94],{"type":37,"tag":74,"props":75,"children":76},"li",{},[77,82],{"type":37,"tag":52,"props":78,"children":79},{},[80],{"type":43,"value":81},"User retries",{"type":43,"value":83}," -- double-click, refresh, back-button-and-resubmit. Client sends the same request twice intentionally.",{"type":37,"tag":74,"props":85,"children":86},{},[87,92],{"type":37,"tag":52,"props":88,"children":89},{},[90],{"type":43,"value":91},"Network retries",{"type":43,"value":93}," -- the operation succeeded but the response was lost (timeout, TCP reset, LB cut). Client retries, not knowing the first attempt worked.",{"type":37,"tag":74,"props":95,"children":96},{},[97,102],{"type":37,"tag":52,"props":98,"children":99},{},[100],{"type":43,"value":101},"Infrastructure redelivery",{"type":43,"value":103}," -- webhook providers retry on timeout, message queues deliver \"at least once,\" cron jobs overlap. Infrastructure sends the same work twice.",{"type":37,"tag":58,"props":105,"children":107},{"id":106},"naturally-idempotent-vs-not",[108],{"type":43,"value":109},"Naturally Idempotent vs Not",{"type":37,"tag":111,"props":112,"children":113},"table",{},[114,133],{"type":37,"tag":115,"props":116,"children":117},"thead",{},[118],{"type":37,"tag":119,"props":120,"children":121},"tr",{},[122,128],{"type":37,"tag":123,"props":124,"children":125},"th",{},[126],{"type":43,"value":127},"Naturally idempotent (safe to repeat)",{"type":37,"tag":123,"props":129,"children":130},{},[131],{"type":43,"value":132},"NOT idempotent (dangerous to repeat)",{"type":37,"tag":134,"props":135,"children":136},"tbody",{},[137,160,181,202,223,240],{"type":37,"tag":119,"props":138,"children":139},{},[140,151],{"type":37,"tag":141,"props":142,"children":143},"td",{},[144],{"type":37,"tag":145,"props":146,"children":148},"code",{"className":147},[],[149],{"type":43,"value":150},"SET x = 5",{"type":37,"tag":141,"props":152,"children":153},{},[154],{"type":37,"tag":145,"props":155,"children":157},{"className":156},[],[158],{"type":43,"value":159},"SET x = x + 1",{"type":37,"tag":119,"props":161,"children":162},{},[163,172],{"type":37,"tag":141,"props":164,"children":165},{},[166],{"type":37,"tag":145,"props":167,"children":169},{"className":168},[],[170],{"type":43,"value":171},"UPDATE status = 'paid' WHERE id = ?",{"type":37,"tag":141,"props":173,"children":174},{},[175],{"type":37,"tag":145,"props":176,"children":178},{"className":177},[],[179],{"type":43,"value":180},"INSERT INTO orders (...)",{"type":37,"tag":119,"props":182,"children":183},{},[184,193],{"type":37,"tag":141,"props":185,"children":186},{},[187],{"type":37,"tag":145,"props":188,"children":190},{"className":189},[],[191],{"type":43,"value":192},"DELETE WHERE id = ?",{"type":37,"tag":141,"props":194,"children":195},{},[196],{"type":37,"tag":145,"props":197,"children":199},{"className":198},[],[200],{"type":43,"value":201},"balance += amount",{"type":37,"tag":119,"props":203,"children":204},{},[205,214],{"type":37,"tag":141,"props":206,"children":207},{},[208],{"type":37,"tag":145,"props":209,"children":211},{"className":210},[],[212],{"type":43,"value":213},"PUT \u002Fusers\u002F123 {full body}",{"type":37,"tag":141,"props":215,"children":216},{},[217],{"type":37,"tag":145,"props":218,"children":220},{"className":219},[],[221],{"type":43,"value":222},"POST \u002Forders {new order}",{"type":37,"tag":119,"props":224,"children":225},{},[226,231],{"type":37,"tag":141,"props":227,"children":228},{},[229],{"type":43,"value":230},"Upsert (INSERT ... ON CONFLICT UPDATE)",{"type":37,"tag":141,"props":232,"children":233},{},[234],{"type":37,"tag":145,"props":235,"children":237},{"className":236},[],[238],{"type":43,"value":239},"sendEmail(user, template)",{"type":37,"tag":119,"props":241,"children":242},{},[243,246],{"type":37,"tag":141,"props":244,"children":245},{},[],{"type":37,"tag":141,"props":247,"children":248},{},[249],{"type":37,"tag":145,"props":250,"children":252},{"className":251},[],[253],{"type":43,"value":254},"stripe.charges.create(...)",{"type":37,"tag":46,"props":256,"children":257},{},[258,263],{"type":37,"tag":52,"props":259,"children":260},{},[261],{"type":43,"value":262},"Design for natural idempotency first.",{"type":43,"value":264}," If you can express the operation as \"set to this state\" rather than \"apply this change,\" it's inherently safe.",{"type":37,"tag":58,"props":266,"children":268},{"id":267},"detection-non-idempotent-code",[269],{"type":43,"value":270},"Detection: Non-Idempotent Code",{"type":37,"tag":46,"props":272,"children":273},{},[274],{"type":37,"tag":52,"props":275,"children":276},{},[277],{"type":43,"value":278},"Stop and add idempotency protection if you see:",{"type":37,"tag":70,"props":280,"children":281},{},[282,292,318,328,354,378],{"type":37,"tag":74,"props":283,"children":284},{},[285,290],{"type":37,"tag":52,"props":286,"children":287},{},[288],{"type":43,"value":289},"A POST handler that creates a record without an idempotency key",{"type":43,"value":291}," -- double-submit creates duplicates.",{"type":37,"tag":74,"props":293,"children":294},{},[295,300,302,308,310,316],{"type":37,"tag":52,"props":296,"children":297},{},[298],{"type":43,"value":299},"Retry logic wrapping a non-idempotent call",{"type":43,"value":301}," -- retrying ",{"type":37,"tag":145,"props":303,"children":305},{"className":304},[],[306],{"type":43,"value":307},"stripe.charges.create()",{"type":43,"value":309}," without an idempotency key double-charges; retrying ",{"type":37,"tag":145,"props":311,"children":313},{"className":312},[],[314],{"type":43,"value":315},"POST \u002Forders",{"type":43,"value":317}," creates duplicates.",{"type":37,"tag":74,"props":319,"children":320},{},[321,326],{"type":37,"tag":52,"props":322,"children":323},{},[324],{"type":43,"value":325},"A webhook handler that doesn't record processed event IDs",{"type":43,"value":327}," -- Stripe, GitHub, Twilio all document that they may resend the same event.",{"type":37,"tag":74,"props":329,"children":330},{},[331,352],{"type":37,"tag":52,"props":332,"children":333},{},[334,336,342,344,350],{"type":43,"value":335},"A queue consumer that uses ",{"type":37,"tag":145,"props":337,"children":339},{"className":338},[],[340],{"type":43,"value":341},"INCREMENT",{"type":43,"value":343}," or ",{"type":37,"tag":145,"props":345,"children":347},{"className":346},[],[348],{"type":43,"value":349},"INSERT",{"type":43,"value":351}," without deduplication",{"type":43,"value":353}," -- SQS, RabbitMQ, Kafka (at-least-once) can all deliver the same message twice.",{"type":37,"tag":74,"props":355,"children":356},{},[357,376],{"type":37,"tag":52,"props":358,"children":359},{},[360,366,368,374],{"type":37,"tag":145,"props":361,"children":363},{"className":362},[],[364],{"type":43,"value":365},"sendEmail()",{"type":43,"value":367},", ",{"type":37,"tag":145,"props":369,"children":371},{"className":370},[],[372],{"type":43,"value":373},"sendSMS()",{"type":43,"value":375},", or any notification call without a dedup check",{"type":43,"value":377}," -- the user gets two of everything.",{"type":37,"tag":74,"props":379,"children":380},{},[381,386],{"type":37,"tag":52,"props":382,"children":383},{},[384],{"type":43,"value":385},"Multi-step operations where early steps have side effects",{"type":43,"value":387}," -- if step 3 fails and the client retries, steps 1 and 2 run again. Are they safe to repeat?",{"type":37,"tag":58,"props":389,"children":391},{"id":390},"patterns",[392],{"type":43,"value":393},"Patterns",{"type":37,"tag":395,"props":396,"children":398},"h3",{"id":397},"idempotency-key-for-api-endpoints",[399],{"type":43,"value":400},"Idempotency key (for API endpoints)",{"type":37,"tag":46,"props":402,"children":403},{},[404],{"type":43,"value":405},"The client generates a unique key (UUID) and sends it with the request; the server detects retries by the key.",{"type":37,"tag":407,"props":408,"children":413},"pre",{"className":409,"code":410,"language":411,"meta":412,"style":412},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","app.post(\"\u002Fapi\u002Forders\", async (req, res) => {\n  const idempotencyKey = req.headers[\"idempotency-key\"];\n  if (!idempotencyKey) {\n    return res.status(400).json({ error: \"Idempotency-Key header required\" });\n  }\n\n  \u002F\u002F Return stored response if already processed\n  const existing = await db.idempotencyRecord.findUnique({ where: { key: idempotencyKey } });\n  if (existing?.status === \"complete\") {\n    return res.status(existing.statusCode).json(existing.responseBody);\n  }\n\n  \u002F\u002F Claim key + create business data in ONE transaction (unique constraint loses the race for one of two retries)\n  const order = await db.$transaction(async (tx) => {\n    await tx.idempotencyRecord.create({ data: { key: idempotencyKey, status: \"processing\" } });\n    return tx.order.create({\n      data: { userId: req.user.id, items: req.body.items, total: req.body.total },\n    });\n  });\n\n  \u002F\u002F External side effects get THEIR OWN key derived from the original\n  await stripe.paymentIntents.create(\n    { customer: req.user.id, amount: order.total, currency: \"usd\" },\n    { idempotencyKey: `charge-${idempotencyKey}` }\n  );\n\n  \u002F\u002F Store response so duplicates get the SAME response as the original\n  await db.idempotencyRecord.update({\n    where: { key: idempotencyKey },\n    data: { status: \"complete\", statusCode: 201, responseBody: order },\n  });\n\n  res.status(201).json(order);\n});\n","typescript","",[414],{"type":37,"tag":145,"props":415,"children":416},{"__ignoreMap":412},[417,506,568,601,692,701,711,721,817,869,943,951,959,968,1032,1138,1175,1297,1314,1331,1339,1348,1384,1477,1522,1535,1543,1552,1589,1622,1698,1714,1722,1776],{"type":37,"tag":418,"props":419,"children":421},"span",{"class":420,"line":24},"line",[422,428,434,440,445,450,456,460,465,471,476,482,486,491,496,501],{"type":37,"tag":418,"props":423,"children":425},{"style":424},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[426],{"type":43,"value":427},"app",{"type":37,"tag":418,"props":429,"children":431},{"style":430},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[432],{"type":43,"value":433},".",{"type":37,"tag":418,"props":435,"children":437},{"style":436},"--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF",[438],{"type":43,"value":439},"post",{"type":37,"tag":418,"props":441,"children":442},{"style":424},[443],{"type":43,"value":444},"(",{"type":37,"tag":418,"props":446,"children":447},{"style":430},[448],{"type":43,"value":449},"\"",{"type":37,"tag":418,"props":451,"children":453},{"style":452},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[454],{"type":43,"value":455},"\u002Fapi\u002Forders",{"type":37,"tag":418,"props":457,"children":458},{"style":430},[459],{"type":43,"value":449},{"type":37,"tag":418,"props":461,"children":462},{"style":430},[463],{"type":43,"value":464},",",{"type":37,"tag":418,"props":466,"children":468},{"style":467},"--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA",[469],{"type":43,"value":470}," async",{"type":37,"tag":418,"props":472,"children":473},{"style":430},[474],{"type":43,"value":475}," (",{"type":37,"tag":418,"props":477,"children":479},{"style":478},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic",[480],{"type":43,"value":481},"req",{"type":37,"tag":418,"props":483,"children":484},{"style":430},[485],{"type":43,"value":464},{"type":37,"tag":418,"props":487,"children":488},{"style":478},[489],{"type":43,"value":490}," res",{"type":37,"tag":418,"props":492,"children":493},{"style":430},[494],{"type":43,"value":495},")",{"type":37,"tag":418,"props":497,"children":498},{"style":467},[499],{"type":43,"value":500}," =>",{"type":37,"tag":418,"props":502,"children":503},{"style":430},[504],{"type":43,"value":505}," {\n",{"type":37,"tag":418,"props":507,"children":509},{"class":420,"line":508},2,[510,515,520,525,530,534,539,545,549,554,558,563],{"type":37,"tag":418,"props":511,"children":512},{"style":467},[513],{"type":43,"value":514},"  const",{"type":37,"tag":418,"props":516,"children":517},{"style":424},[518],{"type":43,"value":519}," idempotencyKey",{"type":37,"tag":418,"props":521,"children":522},{"style":430},[523],{"type":43,"value":524}," =",{"type":37,"tag":418,"props":526,"children":527},{"style":424},[528],{"type":43,"value":529}," req",{"type":37,"tag":418,"props":531,"children":532},{"style":430},[533],{"type":43,"value":433},{"type":37,"tag":418,"props":535,"children":536},{"style":424},[537],{"type":43,"value":538},"headers",{"type":37,"tag":418,"props":540,"children":542},{"style":541},"--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178",[543],{"type":43,"value":544},"[",{"type":37,"tag":418,"props":546,"children":547},{"style":430},[548],{"type":43,"value":449},{"type":37,"tag":418,"props":550,"children":551},{"style":452},[552],{"type":43,"value":553},"idempotency-key",{"type":37,"tag":418,"props":555,"children":556},{"style":430},[557],{"type":43,"value":449},{"type":37,"tag":418,"props":559,"children":560},{"style":541},[561],{"type":43,"value":562},"]",{"type":37,"tag":418,"props":564,"children":565},{"style":430},[566],{"type":43,"value":567},";\n",{"type":37,"tag":418,"props":569,"children":570},{"class":420,"line":20},[571,577,581,586,591,596],{"type":37,"tag":418,"props":572,"children":574},{"style":573},"--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic",[575],{"type":43,"value":576},"  if",{"type":37,"tag":418,"props":578,"children":579},{"style":541},[580],{"type":43,"value":475},{"type":37,"tag":418,"props":582,"children":583},{"style":430},[584],{"type":43,"value":585},"!",{"type":37,"tag":418,"props":587,"children":588},{"style":424},[589],{"type":43,"value":590},"idempotencyKey",{"type":37,"tag":418,"props":592,"children":593},{"style":541},[594],{"type":43,"value":595},") ",{"type":37,"tag":418,"props":597,"children":598},{"style":430},[599],{"type":43,"value":600},"{\n",{"type":37,"tag":418,"props":602,"children":604},{"class":420,"line":603},4,[605,610,614,618,623,627,633,637,641,646,650,655,660,665,670,675,679,684,688],{"type":37,"tag":418,"props":606,"children":607},{"style":573},[608],{"type":43,"value":609},"    return",{"type":37,"tag":418,"props":611,"children":612},{"style":424},[613],{"type":43,"value":490},{"type":37,"tag":418,"props":615,"children":616},{"style":430},[617],{"type":43,"value":433},{"type":37,"tag":418,"props":619,"children":620},{"style":436},[621],{"type":43,"value":622},"status",{"type":37,"tag":418,"props":624,"children":625},{"style":541},[626],{"type":43,"value":444},{"type":37,"tag":418,"props":628,"children":630},{"style":629},"--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C",[631],{"type":43,"value":632},"400",{"type":37,"tag":418,"props":634,"children":635},{"style":541},[636],{"type":43,"value":495},{"type":37,"tag":418,"props":638,"children":639},{"style":430},[640],{"type":43,"value":433},{"type":37,"tag":418,"props":642,"children":643},{"style":436},[644],{"type":43,"value":645},"json",{"type":37,"tag":418,"props":647,"children":648},{"style":541},[649],{"type":43,"value":444},{"type":37,"tag":418,"props":651,"children":652},{"style":430},[653],{"type":43,"value":654},"{",{"type":37,"tag":418,"props":656,"children":657},{"style":541},[658],{"type":43,"value":659}," error",{"type":37,"tag":418,"props":661,"children":662},{"style":430},[663],{"type":43,"value":664},":",{"type":37,"tag":418,"props":666,"children":667},{"style":430},[668],{"type":43,"value":669}," \"",{"type":37,"tag":418,"props":671,"children":672},{"style":452},[673],{"type":43,"value":674},"Idempotency-Key header required",{"type":37,"tag":418,"props":676,"children":677},{"style":430},[678],{"type":43,"value":449},{"type":37,"tag":418,"props":680,"children":681},{"style":430},[682],{"type":43,"value":683}," }",{"type":37,"tag":418,"props":685,"children":686},{"style":541},[687],{"type":43,"value":495},{"type":37,"tag":418,"props":689,"children":690},{"style":430},[691],{"type":43,"value":567},{"type":37,"tag":418,"props":693,"children":695},{"class":420,"line":694},5,[696],{"type":37,"tag":418,"props":697,"children":698},{"style":430},[699],{"type":43,"value":700},"  }\n",{"type":37,"tag":418,"props":702,"children":704},{"class":420,"line":703},6,[705],{"type":37,"tag":418,"props":706,"children":708},{"emptyLinePlaceholder":707},true,[709],{"type":43,"value":710},"\n",{"type":37,"tag":418,"props":712,"children":714},{"class":420,"line":713},7,[715],{"type":37,"tag":418,"props":716,"children":718},{"style":717},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[719],{"type":43,"value":720},"  \u002F\u002F Return stored response if already processed\n",{"type":37,"tag":418,"props":722,"children":724},{"class":420,"line":723},8,[725,729,734,738,743,748,752,757,761,766,770,774,779,783,788,793,797,801,805,809,813],{"type":37,"tag":418,"props":726,"children":727},{"style":467},[728],{"type":43,"value":514},{"type":37,"tag":418,"props":730,"children":731},{"style":424},[732],{"type":43,"value":733}," existing",{"type":37,"tag":418,"props":735,"children":736},{"style":430},[737],{"type":43,"value":524},{"type":37,"tag":418,"props":739,"children":740},{"style":573},[741],{"type":43,"value":742}," await",{"type":37,"tag":418,"props":744,"children":745},{"style":424},[746],{"type":43,"value":747}," db",{"type":37,"tag":418,"props":749,"children":750},{"style":430},[751],{"type":43,"value":433},{"type":37,"tag":418,"props":753,"children":754},{"style":424},[755],{"type":43,"value":756},"idempotencyRecord",{"type":37,"tag":418,"props":758,"children":759},{"style":430},[760],{"type":43,"value":433},{"type":37,"tag":418,"props":762,"children":763},{"style":436},[764],{"type":43,"value":765},"findUnique",{"type":37,"tag":418,"props":767,"children":768},{"style":541},[769],{"type":43,"value":444},{"type":37,"tag":418,"props":771,"children":772},{"style":430},[773],{"type":43,"value":654},{"type":37,"tag":418,"props":775,"children":776},{"style":541},[777],{"type":43,"value":778}," where",{"type":37,"tag":418,"props":780,"children":781},{"style":430},[782],{"type":43,"value":664},{"type":37,"tag":418,"props":784,"children":785},{"style":430},[786],{"type":43,"value":787}," {",{"type":37,"tag":418,"props":789,"children":790},{"style":541},[791],{"type":43,"value":792}," key",{"type":37,"tag":418,"props":794,"children":795},{"style":430},[796],{"type":43,"value":664},{"type":37,"tag":418,"props":798,"children":799},{"style":424},[800],{"type":43,"value":519},{"type":37,"tag":418,"props":802,"children":803},{"style":430},[804],{"type":43,"value":683},{"type":37,"tag":418,"props":806,"children":807},{"style":430},[808],{"type":43,"value":683},{"type":37,"tag":418,"props":810,"children":811},{"style":541},[812],{"type":43,"value":495},{"type":37,"tag":418,"props":814,"children":815},{"style":430},[816],{"type":43,"value":567},{"type":37,"tag":418,"props":818,"children":820},{"class":420,"line":819},9,[821,825,829,834,839,843,848,852,857,861,865],{"type":37,"tag":418,"props":822,"children":823},{"style":573},[824],{"type":43,"value":576},{"type":37,"tag":418,"props":826,"children":827},{"style":541},[828],{"type":43,"value":475},{"type":37,"tag":418,"props":830,"children":831},{"style":424},[832],{"type":43,"value":833},"existing",{"type":37,"tag":418,"props":835,"children":836},{"style":430},[837],{"type":43,"value":838},"?.",{"type":37,"tag":418,"props":840,"children":841},{"style":424},[842],{"type":43,"value":622},{"type":37,"tag":418,"props":844,"children":845},{"style":430},[846],{"type":43,"value":847}," ===",{"type":37,"tag":418,"props":849,"children":850},{"style":430},[851],{"type":43,"value":669},{"type":37,"tag":418,"props":853,"children":854},{"style":452},[855],{"type":43,"value":856},"complete",{"type":37,"tag":418,"props":858,"children":859},{"style":430},[860],{"type":43,"value":449},{"type":37,"tag":418,"props":862,"children":863},{"style":541},[864],{"type":43,"value":595},{"type":37,"tag":418,"props":866,"children":867},{"style":430},[868],{"type":43,"value":600},{"type":37,"tag":418,"props":870,"children":872},{"class":420,"line":871},10,[873,877,881,885,889,893,897,901,906,910,914,918,922,926,930,935,939],{"type":37,"tag":418,"props":874,"children":875},{"style":573},[876],{"type":43,"value":609},{"type":37,"tag":418,"props":878,"children":879},{"style":424},[880],{"type":43,"value":490},{"type":37,"tag":418,"props":882,"children":883},{"style":430},[884],{"type":43,"value":433},{"type":37,"tag":418,"props":886,"children":887},{"style":436},[888],{"type":43,"value":622},{"type":37,"tag":418,"props":890,"children":891},{"style":541},[892],{"type":43,"value":444},{"type":37,"tag":418,"props":894,"children":895},{"style":424},[896],{"type":43,"value":833},{"type":37,"tag":418,"props":898,"children":899},{"style":430},[900],{"type":43,"value":433},{"type":37,"tag":418,"props":902,"children":903},{"style":424},[904],{"type":43,"value":905},"statusCode",{"type":37,"tag":418,"props":907,"children":908},{"style":541},[909],{"type":43,"value":495},{"type":37,"tag":418,"props":911,"children":912},{"style":430},[913],{"type":43,"value":433},{"type":37,"tag":418,"props":915,"children":916},{"style":436},[917],{"type":43,"value":645},{"type":37,"tag":418,"props":919,"children":920},{"style":541},[921],{"type":43,"value":444},{"type":37,"tag":418,"props":923,"children":924},{"style":424},[925],{"type":43,"value":833},{"type":37,"tag":418,"props":927,"children":928},{"style":430},[929],{"type":43,"value":433},{"type":37,"tag":418,"props":931,"children":932},{"style":424},[933],{"type":43,"value":934},"responseBody",{"type":37,"tag":418,"props":936,"children":937},{"style":541},[938],{"type":43,"value":495},{"type":37,"tag":418,"props":940,"children":941},{"style":430},[942],{"type":43,"value":567},{"type":37,"tag":418,"props":944,"children":946},{"class":420,"line":945},11,[947],{"type":37,"tag":418,"props":948,"children":949},{"style":430},[950],{"type":43,"value":700},{"type":37,"tag":418,"props":952,"children":954},{"class":420,"line":953},12,[955],{"type":37,"tag":418,"props":956,"children":957},{"emptyLinePlaceholder":707},[958],{"type":43,"value":710},{"type":37,"tag":418,"props":960,"children":962},{"class":420,"line":961},13,[963],{"type":37,"tag":418,"props":964,"children":965},{"style":717},[966],{"type":43,"value":967},"  \u002F\u002F Claim key + create business data in ONE transaction (unique constraint loses the race for one of two retries)\n",{"type":37,"tag":418,"props":969,"children":971},{"class":420,"line":970},14,[972,976,981,985,989,993,997,1002,1006,1011,1015,1020,1024,1028],{"type":37,"tag":418,"props":973,"children":974},{"style":467},[975],{"type":43,"value":514},{"type":37,"tag":418,"props":977,"children":978},{"style":424},[979],{"type":43,"value":980}," order",{"type":37,"tag":418,"props":982,"children":983},{"style":430},[984],{"type":43,"value":524},{"type":37,"tag":418,"props":986,"children":987},{"style":573},[988],{"type":43,"value":742},{"type":37,"tag":418,"props":990,"children":991},{"style":424},[992],{"type":43,"value":747},{"type":37,"tag":418,"props":994,"children":995},{"style":430},[996],{"type":43,"value":433},{"type":37,"tag":418,"props":998,"children":999},{"style":436},[1000],{"type":43,"value":1001},"$transaction",{"type":37,"tag":418,"props":1003,"children":1004},{"style":541},[1005],{"type":43,"value":444},{"type":37,"tag":418,"props":1007,"children":1008},{"style":467},[1009],{"type":43,"value":1010},"async",{"type":37,"tag":418,"props":1012,"children":1013},{"style":430},[1014],{"type":43,"value":475},{"type":37,"tag":418,"props":1016,"children":1017},{"style":478},[1018],{"type":43,"value":1019},"tx",{"type":37,"tag":418,"props":1021,"children":1022},{"style":430},[1023],{"type":43,"value":495},{"type":37,"tag":418,"props":1025,"children":1026},{"style":467},[1027],{"type":43,"value":500},{"type":37,"tag":418,"props":1029,"children":1030},{"style":430},[1031],{"type":43,"value":505},{"type":37,"tag":418,"props":1033,"children":1035},{"class":420,"line":1034},15,[1036,1041,1046,1050,1054,1058,1063,1067,1071,1076,1080,1084,1088,1092,1096,1100,1105,1109,1113,1118,1122,1126,1130,1134],{"type":37,"tag":418,"props":1037,"children":1038},{"style":573},[1039],{"type":43,"value":1040},"    await",{"type":37,"tag":418,"props":1042,"children":1043},{"style":424},[1044],{"type":43,"value":1045}," tx",{"type":37,"tag":418,"props":1047,"children":1048},{"style":430},[1049],{"type":43,"value":433},{"type":37,"tag":418,"props":1051,"children":1052},{"style":424},[1053],{"type":43,"value":756},{"type":37,"tag":418,"props":1055,"children":1056},{"style":430},[1057],{"type":43,"value":433},{"type":37,"tag":418,"props":1059,"children":1060},{"style":436},[1061],{"type":43,"value":1062},"create",{"type":37,"tag":418,"props":1064,"children":1065},{"style":541},[1066],{"type":43,"value":444},{"type":37,"tag":418,"props":1068,"children":1069},{"style":430},[1070],{"type":43,"value":654},{"type":37,"tag":418,"props":1072,"children":1073},{"style":541},[1074],{"type":43,"value":1075}," data",{"type":37,"tag":418,"props":1077,"children":1078},{"style":430},[1079],{"type":43,"value":664},{"type":37,"tag":418,"props":1081,"children":1082},{"style":430},[1083],{"type":43,"value":787},{"type":37,"tag":418,"props":1085,"children":1086},{"style":541},[1087],{"type":43,"value":792},{"type":37,"tag":418,"props":1089,"children":1090},{"style":430},[1091],{"type":43,"value":664},{"type":37,"tag":418,"props":1093,"children":1094},{"style":424},[1095],{"type":43,"value":519},{"type":37,"tag":418,"props":1097,"children":1098},{"style":430},[1099],{"type":43,"value":464},{"type":37,"tag":418,"props":1101,"children":1102},{"style":541},[1103],{"type":43,"value":1104}," status",{"type":37,"tag":418,"props":1106,"children":1107},{"style":430},[1108],{"type":43,"value":664},{"type":37,"tag":418,"props":1110,"children":1111},{"style":430},[1112],{"type":43,"value":669},{"type":37,"tag":418,"props":1114,"children":1115},{"style":452},[1116],{"type":43,"value":1117},"processing",{"type":37,"tag":418,"props":1119,"children":1120},{"style":430},[1121],{"type":43,"value":449},{"type":37,"tag":418,"props":1123,"children":1124},{"style":430},[1125],{"type":43,"value":683},{"type":37,"tag":418,"props":1127,"children":1128},{"style":430},[1129],{"type":43,"value":683},{"type":37,"tag":418,"props":1131,"children":1132},{"style":541},[1133],{"type":43,"value":495},{"type":37,"tag":418,"props":1135,"children":1136},{"style":430},[1137],{"type":43,"value":567},{"type":37,"tag":418,"props":1139,"children":1141},{"class":420,"line":1140},16,[1142,1146,1150,1154,1159,1163,1167,1171],{"type":37,"tag":418,"props":1143,"children":1144},{"style":573},[1145],{"type":43,"value":609},{"type":37,"tag":418,"props":1147,"children":1148},{"style":424},[1149],{"type":43,"value":1045},{"type":37,"tag":418,"props":1151,"children":1152},{"style":430},[1153],{"type":43,"value":433},{"type":37,"tag":418,"props":1155,"children":1156},{"style":424},[1157],{"type":43,"value":1158},"order",{"type":37,"tag":418,"props":1160,"children":1161},{"style":430},[1162],{"type":43,"value":433},{"type":37,"tag":418,"props":1164,"children":1165},{"style":436},[1166],{"type":43,"value":1062},{"type":37,"tag":418,"props":1168,"children":1169},{"style":541},[1170],{"type":43,"value":444},{"type":37,"tag":418,"props":1172,"children":1173},{"style":430},[1174],{"type":43,"value":600},{"type":37,"tag":418,"props":1176,"children":1178},{"class":420,"line":1177},17,[1179,1184,1188,1192,1197,1201,1205,1209,1214,1218,1223,1227,1232,1236,1240,1244,1249,1253,1258,1262,1267,1271,1275,1279,1283,1287,1292],{"type":37,"tag":418,"props":1180,"children":1181},{"style":541},[1182],{"type":43,"value":1183},"      data",{"type":37,"tag":418,"props":1185,"children":1186},{"style":430},[1187],{"type":43,"value":664},{"type":37,"tag":418,"props":1189,"children":1190},{"style":430},[1191],{"type":43,"value":787},{"type":37,"tag":418,"props":1193,"children":1194},{"style":541},[1195],{"type":43,"value":1196}," userId",{"type":37,"tag":418,"props":1198,"children":1199},{"style":430},[1200],{"type":43,"value":664},{"type":37,"tag":418,"props":1202,"children":1203},{"style":424},[1204],{"type":43,"value":529},{"type":37,"tag":418,"props":1206,"children":1207},{"style":430},[1208],{"type":43,"value":433},{"type":37,"tag":418,"props":1210,"children":1211},{"style":424},[1212],{"type":43,"value":1213},"user",{"type":37,"tag":418,"props":1215,"children":1216},{"style":430},[1217],{"type":43,"value":433},{"type":37,"tag":418,"props":1219,"children":1220},{"style":424},[1221],{"type":43,"value":1222},"id",{"type":37,"tag":418,"props":1224,"children":1225},{"style":430},[1226],{"type":43,"value":464},{"type":37,"tag":418,"props":1228,"children":1229},{"style":541},[1230],{"type":43,"value":1231}," items",{"type":37,"tag":418,"props":1233,"children":1234},{"style":430},[1235],{"type":43,"value":664},{"type":37,"tag":418,"props":1237,"children":1238},{"style":424},[1239],{"type":43,"value":529},{"type":37,"tag":418,"props":1241,"children":1242},{"style":430},[1243],{"type":43,"value":433},{"type":37,"tag":418,"props":1245,"children":1246},{"style":424},[1247],{"type":43,"value":1248},"body",{"type":37,"tag":418,"props":1250,"children":1251},{"style":430},[1252],{"type":43,"value":433},{"type":37,"tag":418,"props":1254,"children":1255},{"style":424},[1256],{"type":43,"value":1257},"items",{"type":37,"tag":418,"props":1259,"children":1260},{"style":430},[1261],{"type":43,"value":464},{"type":37,"tag":418,"props":1263,"children":1264},{"style":541},[1265],{"type":43,"value":1266}," total",{"type":37,"tag":418,"props":1268,"children":1269},{"style":430},[1270],{"type":43,"value":664},{"type":37,"tag":418,"props":1272,"children":1273},{"style":424},[1274],{"type":43,"value":529},{"type":37,"tag":418,"props":1276,"children":1277},{"style":430},[1278],{"type":43,"value":433},{"type":37,"tag":418,"props":1280,"children":1281},{"style":424},[1282],{"type":43,"value":1248},{"type":37,"tag":418,"props":1284,"children":1285},{"style":430},[1286],{"type":43,"value":433},{"type":37,"tag":418,"props":1288,"children":1289},{"style":424},[1290],{"type":43,"value":1291},"total",{"type":37,"tag":418,"props":1293,"children":1294},{"style":430},[1295],{"type":43,"value":1296}," },\n",{"type":37,"tag":418,"props":1298,"children":1300},{"class":420,"line":1299},18,[1301,1306,1310],{"type":37,"tag":418,"props":1302,"children":1303},{"style":430},[1304],{"type":43,"value":1305},"    }",{"type":37,"tag":418,"props":1307,"children":1308},{"style":541},[1309],{"type":43,"value":495},{"type":37,"tag":418,"props":1311,"children":1312},{"style":430},[1313],{"type":43,"value":567},{"type":37,"tag":418,"props":1315,"children":1317},{"class":420,"line":1316},19,[1318,1323,1327],{"type":37,"tag":418,"props":1319,"children":1320},{"style":430},[1321],{"type":43,"value":1322},"  }",{"type":37,"tag":418,"props":1324,"children":1325},{"style":541},[1326],{"type":43,"value":495},{"type":37,"tag":418,"props":1328,"children":1329},{"style":430},[1330],{"type":43,"value":567},{"type":37,"tag":418,"props":1332,"children":1334},{"class":420,"line":1333},20,[1335],{"type":37,"tag":418,"props":1336,"children":1337},{"emptyLinePlaceholder":707},[1338],{"type":43,"value":710},{"type":37,"tag":418,"props":1340,"children":1342},{"class":420,"line":1341},21,[1343],{"type":37,"tag":418,"props":1344,"children":1345},{"style":717},[1346],{"type":43,"value":1347},"  \u002F\u002F External side effects get THEIR OWN key derived from the original\n",{"type":37,"tag":418,"props":1349,"children":1351},{"class":420,"line":1350},22,[1352,1357,1362,1366,1371,1375,1379],{"type":37,"tag":418,"props":1353,"children":1354},{"style":573},[1355],{"type":43,"value":1356},"  await",{"type":37,"tag":418,"props":1358,"children":1359},{"style":424},[1360],{"type":43,"value":1361}," stripe",{"type":37,"tag":418,"props":1363,"children":1364},{"style":430},[1365],{"type":43,"value":433},{"type":37,"tag":418,"props":1367,"children":1368},{"style":424},[1369],{"type":43,"value":1370},"paymentIntents",{"type":37,"tag":418,"props":1372,"children":1373},{"style":430},[1374],{"type":43,"value":433},{"type":37,"tag":418,"props":1376,"children":1377},{"style":436},[1378],{"type":43,"value":1062},{"type":37,"tag":418,"props":1380,"children":1381},{"style":541},[1382],{"type":43,"value":1383},"(\n",{"type":37,"tag":418,"props":1385,"children":1387},{"class":420,"line":1386},23,[1388,1393,1398,1402,1406,1410,1414,1418,1422,1426,1431,1435,1439,1443,1447,1451,1456,1460,1464,1469,1473],{"type":37,"tag":418,"props":1389,"children":1390},{"style":430},[1391],{"type":43,"value":1392},"    {",{"type":37,"tag":418,"props":1394,"children":1395},{"style":541},[1396],{"type":43,"value":1397}," customer",{"type":37,"tag":418,"props":1399,"children":1400},{"style":430},[1401],{"type":43,"value":664},{"type":37,"tag":418,"props":1403,"children":1404},{"style":424},[1405],{"type":43,"value":529},{"type":37,"tag":418,"props":1407,"children":1408},{"style":430},[1409],{"type":43,"value":433},{"type":37,"tag":418,"props":1411,"children":1412},{"style":424},[1413],{"type":43,"value":1213},{"type":37,"tag":418,"props":1415,"children":1416},{"style":430},[1417],{"type":43,"value":433},{"type":37,"tag":418,"props":1419,"children":1420},{"style":424},[1421],{"type":43,"value":1222},{"type":37,"tag":418,"props":1423,"children":1424},{"style":430},[1425],{"type":43,"value":464},{"type":37,"tag":418,"props":1427,"children":1428},{"style":541},[1429],{"type":43,"value":1430}," amount",{"type":37,"tag":418,"props":1432,"children":1433},{"style":430},[1434],{"type":43,"value":664},{"type":37,"tag":418,"props":1436,"children":1437},{"style":424},[1438],{"type":43,"value":980},{"type":37,"tag":418,"props":1440,"children":1441},{"style":430},[1442],{"type":43,"value":433},{"type":37,"tag":418,"props":1444,"children":1445},{"style":424},[1446],{"type":43,"value":1291},{"type":37,"tag":418,"props":1448,"children":1449},{"style":430},[1450],{"type":43,"value":464},{"type":37,"tag":418,"props":1452,"children":1453},{"style":541},[1454],{"type":43,"value":1455}," currency",{"type":37,"tag":418,"props":1457,"children":1458},{"style":430},[1459],{"type":43,"value":664},{"type":37,"tag":418,"props":1461,"children":1462},{"style":430},[1463],{"type":43,"value":669},{"type":37,"tag":418,"props":1465,"children":1466},{"style":452},[1467],{"type":43,"value":1468},"usd",{"type":37,"tag":418,"props":1470,"children":1471},{"style":430},[1472],{"type":43,"value":449},{"type":37,"tag":418,"props":1474,"children":1475},{"style":430},[1476],{"type":43,"value":1296},{"type":37,"tag":418,"props":1478,"children":1480},{"class":420,"line":1479},24,[1481,1485,1489,1493,1498,1503,1508,1512,1517],{"type":37,"tag":418,"props":1482,"children":1483},{"style":430},[1484],{"type":43,"value":1392},{"type":37,"tag":418,"props":1486,"children":1487},{"style":541},[1488],{"type":43,"value":519},{"type":37,"tag":418,"props":1490,"children":1491},{"style":430},[1492],{"type":43,"value":664},{"type":37,"tag":418,"props":1494,"children":1495},{"style":430},[1496],{"type":43,"value":1497}," `",{"type":37,"tag":418,"props":1499,"children":1500},{"style":452},[1501],{"type":43,"value":1502},"charge-",{"type":37,"tag":418,"props":1504,"children":1505},{"style":430},[1506],{"type":43,"value":1507},"${",{"type":37,"tag":418,"props":1509,"children":1510},{"style":424},[1511],{"type":43,"value":590},{"type":37,"tag":418,"props":1513,"children":1514},{"style":430},[1515],{"type":43,"value":1516},"}`",{"type":37,"tag":418,"props":1518,"children":1519},{"style":430},[1520],{"type":43,"value":1521}," }\n",{"type":37,"tag":418,"props":1523,"children":1525},{"class":420,"line":1524},25,[1526,1531],{"type":37,"tag":418,"props":1527,"children":1528},{"style":541},[1529],{"type":43,"value":1530},"  )",{"type":37,"tag":418,"props":1532,"children":1533},{"style":430},[1534],{"type":43,"value":567},{"type":37,"tag":418,"props":1536,"children":1538},{"class":420,"line":1537},26,[1539],{"type":37,"tag":418,"props":1540,"children":1541},{"emptyLinePlaceholder":707},[1542],{"type":43,"value":710},{"type":37,"tag":418,"props":1544,"children":1546},{"class":420,"line":1545},27,[1547],{"type":37,"tag":418,"props":1548,"children":1549},{"style":717},[1550],{"type":43,"value":1551},"  \u002F\u002F Store response so duplicates get the SAME response as the original\n",{"type":37,"tag":418,"props":1553,"children":1555},{"class":420,"line":1554},28,[1556,1560,1564,1568,1572,1576,1581,1585],{"type":37,"tag":418,"props":1557,"children":1558},{"style":573},[1559],{"type":43,"value":1356},{"type":37,"tag":418,"props":1561,"children":1562},{"style":424},[1563],{"type":43,"value":747},{"type":37,"tag":418,"props":1565,"children":1566},{"style":430},[1567],{"type":43,"value":433},{"type":37,"tag":418,"props":1569,"children":1570},{"style":424},[1571],{"type":43,"value":756},{"type":37,"tag":418,"props":1573,"children":1574},{"style":430},[1575],{"type":43,"value":433},{"type":37,"tag":418,"props":1577,"children":1578},{"style":436},[1579],{"type":43,"value":1580},"update",{"type":37,"tag":418,"props":1582,"children":1583},{"style":541},[1584],{"type":43,"value":444},{"type":37,"tag":418,"props":1586,"children":1587},{"style":430},[1588],{"type":43,"value":600},{"type":37,"tag":418,"props":1590,"children":1592},{"class":420,"line":1591},29,[1593,1598,1602,1606,1610,1614,1618],{"type":37,"tag":418,"props":1594,"children":1595},{"style":541},[1596],{"type":43,"value":1597},"    where",{"type":37,"tag":418,"props":1599,"children":1600},{"style":430},[1601],{"type":43,"value":664},{"type":37,"tag":418,"props":1603,"children":1604},{"style":430},[1605],{"type":43,"value":787},{"type":37,"tag":418,"props":1607,"children":1608},{"style":541},[1609],{"type":43,"value":792},{"type":37,"tag":418,"props":1611,"children":1612},{"style":430},[1613],{"type":43,"value":664},{"type":37,"tag":418,"props":1615,"children":1616},{"style":424},[1617],{"type":43,"value":519},{"type":37,"tag":418,"props":1619,"children":1620},{"style":430},[1621],{"type":43,"value":1296},{"type":37,"tag":418,"props":1623,"children":1625},{"class":420,"line":1624},30,[1626,1631,1635,1639,1643,1647,1651,1655,1659,1663,1668,1672,1677,1681,1686,1690,1694],{"type":37,"tag":418,"props":1627,"children":1628},{"style":541},[1629],{"type":43,"value":1630},"    data",{"type":37,"tag":418,"props":1632,"children":1633},{"style":430},[1634],{"type":43,"value":664},{"type":37,"tag":418,"props":1636,"children":1637},{"style":430},[1638],{"type":43,"value":787},{"type":37,"tag":418,"props":1640,"children":1641},{"style":541},[1642],{"type":43,"value":1104},{"type":37,"tag":418,"props":1644,"children":1645},{"style":430},[1646],{"type":43,"value":664},{"type":37,"tag":418,"props":1648,"children":1649},{"style":430},[1650],{"type":43,"value":669},{"type":37,"tag":418,"props":1652,"children":1653},{"style":452},[1654],{"type":43,"value":856},{"type":37,"tag":418,"props":1656,"children":1657},{"style":430},[1658],{"type":43,"value":449},{"type":37,"tag":418,"props":1660,"children":1661},{"style":430},[1662],{"type":43,"value":464},{"type":37,"tag":418,"props":1664,"children":1665},{"style":541},[1666],{"type":43,"value":1667}," statusCode",{"type":37,"tag":418,"props":1669,"children":1670},{"style":430},[1671],{"type":43,"value":664},{"type":37,"tag":418,"props":1673,"children":1674},{"style":629},[1675],{"type":43,"value":1676}," 201",{"type":37,"tag":418,"props":1678,"children":1679},{"style":430},[1680],{"type":43,"value":464},{"type":37,"tag":418,"props":1682,"children":1683},{"style":541},[1684],{"type":43,"value":1685}," responseBody",{"type":37,"tag":418,"props":1687,"children":1688},{"style":430},[1689],{"type":43,"value":664},{"type":37,"tag":418,"props":1691,"children":1692},{"style":424},[1693],{"type":43,"value":980},{"type":37,"tag":418,"props":1695,"children":1696},{"style":430},[1697],{"type":43,"value":1296},{"type":37,"tag":418,"props":1699,"children":1701},{"class":420,"line":1700},31,[1702,1706,1710],{"type":37,"tag":418,"props":1703,"children":1704},{"style":430},[1705],{"type":43,"value":1322},{"type":37,"tag":418,"props":1707,"children":1708},{"style":541},[1709],{"type":43,"value":495},{"type":37,"tag":418,"props":1711,"children":1712},{"style":430},[1713],{"type":43,"value":567},{"type":37,"tag":418,"props":1715,"children":1717},{"class":420,"line":1716},32,[1718],{"type":37,"tag":418,"props":1719,"children":1720},{"emptyLinePlaceholder":707},[1721],{"type":43,"value":710},{"type":37,"tag":418,"props":1723,"children":1725},{"class":420,"line":1724},33,[1726,1731,1735,1739,1743,1748,1752,1756,1760,1764,1768,1772],{"type":37,"tag":418,"props":1727,"children":1728},{"style":424},[1729],{"type":43,"value":1730},"  res",{"type":37,"tag":418,"props":1732,"children":1733},{"style":430},[1734],{"type":43,"value":433},{"type":37,"tag":418,"props":1736,"children":1737},{"style":436},[1738],{"type":43,"value":622},{"type":37,"tag":418,"props":1740,"children":1741},{"style":541},[1742],{"type":43,"value":444},{"type":37,"tag":418,"props":1744,"children":1745},{"style":629},[1746],{"type":43,"value":1747},"201",{"type":37,"tag":418,"props":1749,"children":1750},{"style":541},[1751],{"type":43,"value":495},{"type":37,"tag":418,"props":1753,"children":1754},{"style":430},[1755],{"type":43,"value":433},{"type":37,"tag":418,"props":1757,"children":1758},{"style":436},[1759],{"type":43,"value":645},{"type":37,"tag":418,"props":1761,"children":1762},{"style":541},[1763],{"type":43,"value":444},{"type":37,"tag":418,"props":1765,"children":1766},{"style":424},[1767],{"type":43,"value":1158},{"type":37,"tag":418,"props":1769,"children":1770},{"style":541},[1771],{"type":43,"value":495},{"type":37,"tag":418,"props":1773,"children":1774},{"style":430},[1775],{"type":43,"value":567},{"type":37,"tag":418,"props":1777,"children":1779},{"class":420,"line":1778},34,[1780,1785,1789],{"type":37,"tag":418,"props":1781,"children":1782},{"style":430},[1783],{"type":43,"value":1784},"}",{"type":37,"tag":418,"props":1786,"children":1787},{"style":424},[1788],{"type":43,"value":495},{"type":37,"tag":418,"props":1790,"children":1791},{"style":430},[1792],{"type":43,"value":567},{"type":37,"tag":46,"props":1794,"children":1795},{},[1796,1798,1803,1805,1810],{"type":43,"value":1797},"The three load-bearing details: the idempotency record is created in the ",{"type":37,"tag":52,"props":1799,"children":1800},{},[1801],{"type":43,"value":1802},"same transaction",{"type":43,"value":1804}," as the business data; external APIs get ",{"type":37,"tag":52,"props":1806,"children":1807},{},[1808],{"type":43,"value":1809},"their own",{"type":43,"value":1811}," keys derived from the original; the stored response is replayed on duplicates.",{"type":37,"tag":395,"props":1813,"children":1815},{"id":1814},"webhook-deduplication-for-incoming-webhooks",[1816],{"type":43,"value":1817},"Webhook deduplication (for incoming webhooks)",{"type":37,"tag":46,"props":1819,"children":1820},{},[1821,1823,1829,1831,1836],{"type":43,"value":1822},"Webhook providers include a unique event ID. Record it and skip duplicates. The unique constraint on ",{"type":37,"tag":145,"props":1824,"children":1826},{"className":1825},[],[1827],{"type":43,"value":1828},"eventId",{"type":43,"value":1830}," also catches races between two simultaneous deliveries. Non-transactional side effects (emails) go ",{"type":37,"tag":52,"props":1832,"children":1833},{},[1834],{"type":43,"value":1835},"after",{"type":43,"value":1837}," the dedup gate.",{"type":37,"tag":407,"props":1839,"children":1841},{"className":409,"code":1840,"language":411,"meta":412,"style":412},"app.post(\"\u002Fwebhooks\u002Fstripe\", async (req, res) => {\n  const event = req.body;\n\n  try {\n    await db.$transaction(async (tx) => {\n      await tx.processedWebhookEvent.create({ data: { eventId: event.id, processedAt: new Date() } });\n      if (event.type === \"payment_intent.succeeded\") {\n        await tx.order.update({\n          where: { paymentIntentId: event.data.object.id },\n          data: { status: \"paid\" },\n        });\n      }\n    });\n  } catch (error) {\n    if (isPrismaUniqueConstraintError(error)) {\n      return res.json({ received: true }); \u002F\u002F Already processed, skip\n    }\n    throw error;\n  }\n\n  if (event.type === \"payment_intent.succeeded\") {\n    await sendConfirmationEmail(event.data.object.metadata.userId);\n  }\n  res.json({ received: true });\n});\n",[1842],{"type":37,"tag":145,"props":1843,"children":1844},{"__ignoreMap":412},[1845,1913,1945,1952,1964,2011,2125,2176,2212,2271,2312,2328,2336,2351,2380,2414,2475,2483,2499,2506,2513,2560,2622,2629,2676],{"type":37,"tag":418,"props":1846,"children":1847},{"class":420,"line":24},[1848,1852,1856,1860,1864,1868,1873,1877,1881,1885,1889,1893,1897,1901,1905,1909],{"type":37,"tag":418,"props":1849,"children":1850},{"style":424},[1851],{"type":43,"value":427},{"type":37,"tag":418,"props":1853,"children":1854},{"style":430},[1855],{"type":43,"value":433},{"type":37,"tag":418,"props":1857,"children":1858},{"style":436},[1859],{"type":43,"value":439},{"type":37,"tag":418,"props":1861,"children":1862},{"style":424},[1863],{"type":43,"value":444},{"type":37,"tag":418,"props":1865,"children":1866},{"style":430},[1867],{"type":43,"value":449},{"type":37,"tag":418,"props":1869,"children":1870},{"style":452},[1871],{"type":43,"value":1872},"\u002Fwebhooks\u002Fstripe",{"type":37,"tag":418,"props":1874,"children":1875},{"style":430},[1876],{"type":43,"value":449},{"type":37,"tag":418,"props":1878,"children":1879},{"style":430},[1880],{"type":43,"value":464},{"type":37,"tag":418,"props":1882,"children":1883},{"style":467},[1884],{"type":43,"value":470},{"type":37,"tag":418,"props":1886,"children":1887},{"style":430},[1888],{"type":43,"value":475},{"type":37,"tag":418,"props":1890,"children":1891},{"style":478},[1892],{"type":43,"value":481},{"type":37,"tag":418,"props":1894,"children":1895},{"style":430},[1896],{"type":43,"value":464},{"type":37,"tag":418,"props":1898,"children":1899},{"style":478},[1900],{"type":43,"value":490},{"type":37,"tag":418,"props":1902,"children":1903},{"style":430},[1904],{"type":43,"value":495},{"type":37,"tag":418,"props":1906,"children":1907},{"style":467},[1908],{"type":43,"value":500},{"type":37,"tag":418,"props":1910,"children":1911},{"style":430},[1912],{"type":43,"value":505},{"type":37,"tag":418,"props":1914,"children":1915},{"class":420,"line":508},[1916,1920,1925,1929,1933,1937,1941],{"type":37,"tag":418,"props":1917,"children":1918},{"style":467},[1919],{"type":43,"value":514},{"type":37,"tag":418,"props":1921,"children":1922},{"style":424},[1923],{"type":43,"value":1924}," event",{"type":37,"tag":418,"props":1926,"children":1927},{"style":430},[1928],{"type":43,"value":524},{"type":37,"tag":418,"props":1930,"children":1931},{"style":424},[1932],{"type":43,"value":529},{"type":37,"tag":418,"props":1934,"children":1935},{"style":430},[1936],{"type":43,"value":433},{"type":37,"tag":418,"props":1938,"children":1939},{"style":424},[1940],{"type":43,"value":1248},{"type":37,"tag":418,"props":1942,"children":1943},{"style":430},[1944],{"type":43,"value":567},{"type":37,"tag":418,"props":1946,"children":1947},{"class":420,"line":20},[1948],{"type":37,"tag":418,"props":1949,"children":1950},{"emptyLinePlaceholder":707},[1951],{"type":43,"value":710},{"type":37,"tag":418,"props":1953,"children":1954},{"class":420,"line":603},[1955,1960],{"type":37,"tag":418,"props":1956,"children":1957},{"style":573},[1958],{"type":43,"value":1959},"  try",{"type":37,"tag":418,"props":1961,"children":1962},{"style":430},[1963],{"type":43,"value":505},{"type":37,"tag":418,"props":1965,"children":1966},{"class":420,"line":694},[1967,1971,1975,1979,1983,1987,1991,1995,1999,2003,2007],{"type":37,"tag":418,"props":1968,"children":1969},{"style":573},[1970],{"type":43,"value":1040},{"type":37,"tag":418,"props":1972,"children":1973},{"style":424},[1974],{"type":43,"value":747},{"type":37,"tag":418,"props":1976,"children":1977},{"style":430},[1978],{"type":43,"value":433},{"type":37,"tag":418,"props":1980,"children":1981},{"style":436},[1982],{"type":43,"value":1001},{"type":37,"tag":418,"props":1984,"children":1985},{"style":541},[1986],{"type":43,"value":444},{"type":37,"tag":418,"props":1988,"children":1989},{"style":467},[1990],{"type":43,"value":1010},{"type":37,"tag":418,"props":1992,"children":1993},{"style":430},[1994],{"type":43,"value":475},{"type":37,"tag":418,"props":1996,"children":1997},{"style":478},[1998],{"type":43,"value":1019},{"type":37,"tag":418,"props":2000,"children":2001},{"style":430},[2002],{"type":43,"value":495},{"type":37,"tag":418,"props":2004,"children":2005},{"style":467},[2006],{"type":43,"value":500},{"type":37,"tag":418,"props":2008,"children":2009},{"style":430},[2010],{"type":43,"value":505},{"type":37,"tag":418,"props":2012,"children":2013},{"class":420,"line":703},[2014,2019,2023,2027,2032,2036,2040,2044,2048,2052,2056,2060,2065,2069,2073,2077,2081,2085,2090,2094,2099,2104,2109,2113,2117,2121],{"type":37,"tag":418,"props":2015,"children":2016},{"style":573},[2017],{"type":43,"value":2018},"      await",{"type":37,"tag":418,"props":2020,"children":2021},{"style":424},[2022],{"type":43,"value":1045},{"type":37,"tag":418,"props":2024,"children":2025},{"style":430},[2026],{"type":43,"value":433},{"type":37,"tag":418,"props":2028,"children":2029},{"style":424},[2030],{"type":43,"value":2031},"processedWebhookEvent",{"type":37,"tag":418,"props":2033,"children":2034},{"style":430},[2035],{"type":43,"value":433},{"type":37,"tag":418,"props":2037,"children":2038},{"style":436},[2039],{"type":43,"value":1062},{"type":37,"tag":418,"props":2041,"children":2042},{"style":541},[2043],{"type":43,"value":444},{"type":37,"tag":418,"props":2045,"children":2046},{"style":430},[2047],{"type":43,"value":654},{"type":37,"tag":418,"props":2049,"children":2050},{"style":541},[2051],{"type":43,"value":1075},{"type":37,"tag":418,"props":2053,"children":2054},{"style":430},[2055],{"type":43,"value":664},{"type":37,"tag":418,"props":2057,"children":2058},{"style":430},[2059],{"type":43,"value":787},{"type":37,"tag":418,"props":2061,"children":2062},{"style":541},[2063],{"type":43,"value":2064}," eventId",{"type":37,"tag":418,"props":2066,"children":2067},{"style":430},[2068],{"type":43,"value":664},{"type":37,"tag":418,"props":2070,"children":2071},{"style":424},[2072],{"type":43,"value":1924},{"type":37,"tag":418,"props":2074,"children":2075},{"style":430},[2076],{"type":43,"value":433},{"type":37,"tag":418,"props":2078,"children":2079},{"style":424},[2080],{"type":43,"value":1222},{"type":37,"tag":418,"props":2082,"children":2083},{"style":430},[2084],{"type":43,"value":464},{"type":37,"tag":418,"props":2086,"children":2087},{"style":541},[2088],{"type":43,"value":2089}," processedAt",{"type":37,"tag":418,"props":2091,"children":2092},{"style":430},[2093],{"type":43,"value":664},{"type":37,"tag":418,"props":2095,"children":2096},{"style":430},[2097],{"type":43,"value":2098}," new",{"type":37,"tag":418,"props":2100,"children":2101},{"style":436},[2102],{"type":43,"value":2103}," Date",{"type":37,"tag":418,"props":2105,"children":2106},{"style":541},[2107],{"type":43,"value":2108},"() ",{"type":37,"tag":418,"props":2110,"children":2111},{"style":430},[2112],{"type":43,"value":1784},{"type":37,"tag":418,"props":2114,"children":2115},{"style":430},[2116],{"type":43,"value":683},{"type":37,"tag":418,"props":2118,"children":2119},{"style":541},[2120],{"type":43,"value":495},{"type":37,"tag":418,"props":2122,"children":2123},{"style":430},[2124],{"type":43,"value":567},{"type":37,"tag":418,"props":2126,"children":2127},{"class":420,"line":713},[2128,2133,2137,2142,2146,2151,2155,2159,2164,2168,2172],{"type":37,"tag":418,"props":2129,"children":2130},{"style":573},[2131],{"type":43,"value":2132},"      if",{"type":37,"tag":418,"props":2134,"children":2135},{"style":541},[2136],{"type":43,"value":475},{"type":37,"tag":418,"props":2138,"children":2139},{"style":424},[2140],{"type":43,"value":2141},"event",{"type":37,"tag":418,"props":2143,"children":2144},{"style":430},[2145],{"type":43,"value":433},{"type":37,"tag":418,"props":2147,"children":2148},{"style":424},[2149],{"type":43,"value":2150},"type",{"type":37,"tag":418,"props":2152,"children":2153},{"style":430},[2154],{"type":43,"value":847},{"type":37,"tag":418,"props":2156,"children":2157},{"style":430},[2158],{"type":43,"value":669},{"type":37,"tag":418,"props":2160,"children":2161},{"style":452},[2162],{"type":43,"value":2163},"payment_intent.succeeded",{"type":37,"tag":418,"props":2165,"children":2166},{"style":430},[2167],{"type":43,"value":449},{"type":37,"tag":418,"props":2169,"children":2170},{"style":541},[2171],{"type":43,"value":595},{"type":37,"tag":418,"props":2173,"children":2174},{"style":430},[2175],{"type":43,"value":600},{"type":37,"tag":418,"props":2177,"children":2178},{"class":420,"line":723},[2179,2184,2188,2192,2196,2200,2204,2208],{"type":37,"tag":418,"props":2180,"children":2181},{"style":573},[2182],{"type":43,"value":2183},"        await",{"type":37,"tag":418,"props":2185,"children":2186},{"style":424},[2187],{"type":43,"value":1045},{"type":37,"tag":418,"props":2189,"children":2190},{"style":430},[2191],{"type":43,"value":433},{"type":37,"tag":418,"props":2193,"children":2194},{"style":424},[2195],{"type":43,"value":1158},{"type":37,"tag":418,"props":2197,"children":2198},{"style":430},[2199],{"type":43,"value":433},{"type":37,"tag":418,"props":2201,"children":2202},{"style":436},[2203],{"type":43,"value":1580},{"type":37,"tag":418,"props":2205,"children":2206},{"style":541},[2207],{"type":43,"value":444},{"type":37,"tag":418,"props":2209,"children":2210},{"style":430},[2211],{"type":43,"value":600},{"type":37,"tag":418,"props":2213,"children":2214},{"class":420,"line":819},[2215,2220,2224,2228,2233,2237,2241,2245,2250,2254,2259,2263,2267],{"type":37,"tag":418,"props":2216,"children":2217},{"style":541},[2218],{"type":43,"value":2219},"          where",{"type":37,"tag":418,"props":2221,"children":2222},{"style":430},[2223],{"type":43,"value":664},{"type":37,"tag":418,"props":2225,"children":2226},{"style":430},[2227],{"type":43,"value":787},{"type":37,"tag":418,"props":2229,"children":2230},{"style":541},[2231],{"type":43,"value":2232}," paymentIntentId",{"type":37,"tag":418,"props":2234,"children":2235},{"style":430},[2236],{"type":43,"value":664},{"type":37,"tag":418,"props":2238,"children":2239},{"style":424},[2240],{"type":43,"value":1924},{"type":37,"tag":418,"props":2242,"children":2243},{"style":430},[2244],{"type":43,"value":433},{"type":37,"tag":418,"props":2246,"children":2247},{"style":424},[2248],{"type":43,"value":2249},"data",{"type":37,"tag":418,"props":2251,"children":2252},{"style":430},[2253],{"type":43,"value":433},{"type":37,"tag":418,"props":2255,"children":2256},{"style":424},[2257],{"type":43,"value":2258},"object",{"type":37,"tag":418,"props":2260,"children":2261},{"style":430},[2262],{"type":43,"value":433},{"type":37,"tag":418,"props":2264,"children":2265},{"style":424},[2266],{"type":43,"value":1222},{"type":37,"tag":418,"props":2268,"children":2269},{"style":430},[2270],{"type":43,"value":1296},{"type":37,"tag":418,"props":2272,"children":2273},{"class":420,"line":871},[2274,2279,2283,2287,2291,2295,2299,2304,2308],{"type":37,"tag":418,"props":2275,"children":2276},{"style":541},[2277],{"type":43,"value":2278},"          data",{"type":37,"tag":418,"props":2280,"children":2281},{"style":430},[2282],{"type":43,"value":664},{"type":37,"tag":418,"props":2284,"children":2285},{"style":430},[2286],{"type":43,"value":787},{"type":37,"tag":418,"props":2288,"children":2289},{"style":541},[2290],{"type":43,"value":1104},{"type":37,"tag":418,"props":2292,"children":2293},{"style":430},[2294],{"type":43,"value":664},{"type":37,"tag":418,"props":2296,"children":2297},{"style":430},[2298],{"type":43,"value":669},{"type":37,"tag":418,"props":2300,"children":2301},{"style":452},[2302],{"type":43,"value":2303},"paid",{"type":37,"tag":418,"props":2305,"children":2306},{"style":430},[2307],{"type":43,"value":449},{"type":37,"tag":418,"props":2309,"children":2310},{"style":430},[2311],{"type":43,"value":1296},{"type":37,"tag":418,"props":2313,"children":2314},{"class":420,"line":945},[2315,2320,2324],{"type":37,"tag":418,"props":2316,"children":2317},{"style":430},[2318],{"type":43,"value":2319},"        }",{"type":37,"tag":418,"props":2321,"children":2322},{"style":541},[2323],{"type":43,"value":495},{"type":37,"tag":418,"props":2325,"children":2326},{"style":430},[2327],{"type":43,"value":567},{"type":37,"tag":418,"props":2329,"children":2330},{"class":420,"line":953},[2331],{"type":37,"tag":418,"props":2332,"children":2333},{"style":430},[2334],{"type":43,"value":2335},"      }\n",{"type":37,"tag":418,"props":2337,"children":2338},{"class":420,"line":961},[2339,2343,2347],{"type":37,"tag":418,"props":2340,"children":2341},{"style":430},[2342],{"type":43,"value":1305},{"type":37,"tag":418,"props":2344,"children":2345},{"style":541},[2346],{"type":43,"value":495},{"type":37,"tag":418,"props":2348,"children":2349},{"style":430},[2350],{"type":43,"value":567},{"type":37,"tag":418,"props":2352,"children":2353},{"class":420,"line":970},[2354,2358,2363,2367,2372,2376],{"type":37,"tag":418,"props":2355,"children":2356},{"style":430},[2357],{"type":43,"value":1322},{"type":37,"tag":418,"props":2359,"children":2360},{"style":573},[2361],{"type":43,"value":2362}," catch",{"type":37,"tag":418,"props":2364,"children":2365},{"style":541},[2366],{"type":43,"value":475},{"type":37,"tag":418,"props":2368,"children":2369},{"style":424},[2370],{"type":43,"value":2371},"error",{"type":37,"tag":418,"props":2373,"children":2374},{"style":541},[2375],{"type":43,"value":595},{"type":37,"tag":418,"props":2377,"children":2378},{"style":430},[2379],{"type":43,"value":600},{"type":37,"tag":418,"props":2381,"children":2382},{"class":420,"line":1034},[2383,2388,2392,2397,2401,2405,2410],{"type":37,"tag":418,"props":2384,"children":2385},{"style":573},[2386],{"type":43,"value":2387},"    if",{"type":37,"tag":418,"props":2389,"children":2390},{"style":541},[2391],{"type":43,"value":475},{"type":37,"tag":418,"props":2393,"children":2394},{"style":436},[2395],{"type":43,"value":2396},"isPrismaUniqueConstraintError",{"type":37,"tag":418,"props":2398,"children":2399},{"style":541},[2400],{"type":43,"value":444},{"type":37,"tag":418,"props":2402,"children":2403},{"style":424},[2404],{"type":43,"value":2371},{"type":37,"tag":418,"props":2406,"children":2407},{"style":541},[2408],{"type":43,"value":2409},")) ",{"type":37,"tag":418,"props":2411,"children":2412},{"style":430},[2413],{"type":43,"value":600},{"type":37,"tag":418,"props":2415,"children":2416},{"class":420,"line":1140},[2417,2422,2426,2430,2434,2438,2442,2447,2451,2457,2461,2465,2470],{"type":37,"tag":418,"props":2418,"children":2419},{"style":573},[2420],{"type":43,"value":2421},"      return",{"type":37,"tag":418,"props":2423,"children":2424},{"style":424},[2425],{"type":43,"value":490},{"type":37,"tag":418,"props":2427,"children":2428},{"style":430},[2429],{"type":43,"value":433},{"type":37,"tag":418,"props":2431,"children":2432},{"style":436},[2433],{"type":43,"value":645},{"type":37,"tag":418,"props":2435,"children":2436},{"style":541},[2437],{"type":43,"value":444},{"type":37,"tag":418,"props":2439,"children":2440},{"style":430},[2441],{"type":43,"value":654},{"type":37,"tag":418,"props":2443,"children":2444},{"style":541},[2445],{"type":43,"value":2446}," received",{"type":37,"tag":418,"props":2448,"children":2449},{"style":430},[2450],{"type":43,"value":664},{"type":37,"tag":418,"props":2452,"children":2454},{"style":2453},"--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC",[2455],{"type":43,"value":2456}," true",{"type":37,"tag":418,"props":2458,"children":2459},{"style":430},[2460],{"type":43,"value":683},{"type":37,"tag":418,"props":2462,"children":2463},{"style":541},[2464],{"type":43,"value":495},{"type":37,"tag":418,"props":2466,"children":2467},{"style":430},[2468],{"type":43,"value":2469},";",{"type":37,"tag":418,"props":2471,"children":2472},{"style":717},[2473],{"type":43,"value":2474}," \u002F\u002F Already processed, skip\n",{"type":37,"tag":418,"props":2476,"children":2477},{"class":420,"line":1177},[2478],{"type":37,"tag":418,"props":2479,"children":2480},{"style":430},[2481],{"type":43,"value":2482},"    }\n",{"type":37,"tag":418,"props":2484,"children":2485},{"class":420,"line":1299},[2486,2491,2495],{"type":37,"tag":418,"props":2487,"children":2488},{"style":573},[2489],{"type":43,"value":2490},"    throw",{"type":37,"tag":418,"props":2492,"children":2493},{"style":424},[2494],{"type":43,"value":659},{"type":37,"tag":418,"props":2496,"children":2497},{"style":430},[2498],{"type":43,"value":567},{"type":37,"tag":418,"props":2500,"children":2501},{"class":420,"line":1316},[2502],{"type":37,"tag":418,"props":2503,"children":2504},{"style":430},[2505],{"type":43,"value":700},{"type":37,"tag":418,"props":2507,"children":2508},{"class":420,"line":1333},[2509],{"type":37,"tag":418,"props":2510,"children":2511},{"emptyLinePlaceholder":707},[2512],{"type":43,"value":710},{"type":37,"tag":418,"props":2514,"children":2515},{"class":420,"line":1341},[2516,2520,2524,2528,2532,2536,2540,2544,2548,2552,2556],{"type":37,"tag":418,"props":2517,"children":2518},{"style":573},[2519],{"type":43,"value":576},{"type":37,"tag":418,"props":2521,"children":2522},{"style":541},[2523],{"type":43,"value":475},{"type":37,"tag":418,"props":2525,"children":2526},{"style":424},[2527],{"type":43,"value":2141},{"type":37,"tag":418,"props":2529,"children":2530},{"style":430},[2531],{"type":43,"value":433},{"type":37,"tag":418,"props":2533,"children":2534},{"style":424},[2535],{"type":43,"value":2150},{"type":37,"tag":418,"props":2537,"children":2538},{"style":430},[2539],{"type":43,"value":847},{"type":37,"tag":418,"props":2541,"children":2542},{"style":430},[2543],{"type":43,"value":669},{"type":37,"tag":418,"props":2545,"children":2546},{"style":452},[2547],{"type":43,"value":2163},{"type":37,"tag":418,"props":2549,"children":2550},{"style":430},[2551],{"type":43,"value":449},{"type":37,"tag":418,"props":2553,"children":2554},{"style":541},[2555],{"type":43,"value":595},{"type":37,"tag":418,"props":2557,"children":2558},{"style":430},[2559],{"type":43,"value":600},{"type":37,"tag":418,"props":2561,"children":2562},{"class":420,"line":1350},[2563,2567,2572,2576,2580,2584,2588,2592,2596,2600,2605,2609,2614,2618],{"type":37,"tag":418,"props":2564,"children":2565},{"style":573},[2566],{"type":43,"value":1040},{"type":37,"tag":418,"props":2568,"children":2569},{"style":436},[2570],{"type":43,"value":2571}," sendConfirmationEmail",{"type":37,"tag":418,"props":2573,"children":2574},{"style":541},[2575],{"type":43,"value":444},{"type":37,"tag":418,"props":2577,"children":2578},{"style":424},[2579],{"type":43,"value":2141},{"type":37,"tag":418,"props":2581,"children":2582},{"style":430},[2583],{"type":43,"value":433},{"type":37,"tag":418,"props":2585,"children":2586},{"style":424},[2587],{"type":43,"value":2249},{"type":37,"tag":418,"props":2589,"children":2590},{"style":430},[2591],{"type":43,"value":433},{"type":37,"tag":418,"props":2593,"children":2594},{"style":424},[2595],{"type":43,"value":2258},{"type":37,"tag":418,"props":2597,"children":2598},{"style":430},[2599],{"type":43,"value":433},{"type":37,"tag":418,"props":2601,"children":2602},{"style":424},[2603],{"type":43,"value":2604},"metadata",{"type":37,"tag":418,"props":2606,"children":2607},{"style":430},[2608],{"type":43,"value":433},{"type":37,"tag":418,"props":2610,"children":2611},{"style":424},[2612],{"type":43,"value":2613},"userId",{"type":37,"tag":418,"props":2615,"children":2616},{"style":541},[2617],{"type":43,"value":495},{"type":37,"tag":418,"props":2619,"children":2620},{"style":430},[2621],{"type":43,"value":567},{"type":37,"tag":418,"props":2623,"children":2624},{"class":420,"line":1386},[2625],{"type":37,"tag":418,"props":2626,"children":2627},{"style":430},[2628],{"type":43,"value":700},{"type":37,"tag":418,"props":2630,"children":2631},{"class":420,"line":1479},[2632,2636,2640,2644,2648,2652,2656,2660,2664,2668,2672],{"type":37,"tag":418,"props":2633,"children":2634},{"style":424},[2635],{"type":43,"value":1730},{"type":37,"tag":418,"props":2637,"children":2638},{"style":430},[2639],{"type":43,"value":433},{"type":37,"tag":418,"props":2641,"children":2642},{"style":436},[2643],{"type":43,"value":645},{"type":37,"tag":418,"props":2645,"children":2646},{"style":541},[2647],{"type":43,"value":444},{"type":37,"tag":418,"props":2649,"children":2650},{"style":430},[2651],{"type":43,"value":654},{"type":37,"tag":418,"props":2653,"children":2654},{"style":541},[2655],{"type":43,"value":2446},{"type":37,"tag":418,"props":2657,"children":2658},{"style":430},[2659],{"type":43,"value":664},{"type":37,"tag":418,"props":2661,"children":2662},{"style":2453},[2663],{"type":43,"value":2456},{"type":37,"tag":418,"props":2665,"children":2666},{"style":430},[2667],{"type":43,"value":683},{"type":37,"tag":418,"props":2669,"children":2670},{"style":541},[2671],{"type":43,"value":495},{"type":37,"tag":418,"props":2673,"children":2674},{"style":430},[2675],{"type":43,"value":567},{"type":37,"tag":418,"props":2677,"children":2678},{"class":420,"line":1524},[2679,2683,2687],{"type":37,"tag":418,"props":2680,"children":2681},{"style":430},[2682],{"type":43,"value":1784},{"type":37,"tag":418,"props":2684,"children":2685},{"style":424},[2686],{"type":43,"value":495},{"type":37,"tag":418,"props":2688,"children":2689},{"style":430},[2690],{"type":43,"value":567},{"type":37,"tag":395,"props":2692,"children":2694},{"id":2693},"queue-consumer-deduplication",[2695],{"type":43,"value":2696},"Queue consumer deduplication",{"type":37,"tag":46,"props":2698,"children":2699},{},[2700,2702,2707],{"type":43,"value":2701},"The producer includes a unique transaction\u002Fmessage ID; the consumer records it in the same transaction as the work. On a real error, ",{"type":37,"tag":52,"props":2703,"children":2704},{},[2705],{"type":43,"value":2706},"don't ack",{"type":43,"value":2708}," -- let the queue redeliver.",{"type":37,"tag":407,"props":2710,"children":2712},{"className":409,"code":2711,"language":411,"meta":412,"style":412},"worker.on(\"message\", async (msg) => {\n  const { transactionId, userId, amount } = JSON.parse(msg.body);\n\n  try {\n    await db.$transaction(async (tx) => {\n      \u002F\u002F Unique constraint on transactionId prevents duplicates\n      await tx.processedTransaction.create({ data: { id: transactionId, processedAt: new Date() } });\n      await tx.account.update({ where: { userId }, data: { balance: { increment: amount } } });\n    });\n  } catch (error) {\n    if (isPrismaUniqueConstraintError(error)) {\n      await msg.ack(); \u002F\u002F Already processed -- ack and move on\n      return;\n    }\n    throw error; \u002F\u002F Real error -- don't ack, let queue redeliver\n  }\n\n  await msg.ack();\n});\n",[2713],{"type":37,"tag":145,"props":2714,"children":2715},{"__ignoreMap":412},[2716,2779,2857,2864,2875,2922,2930,3031,3146,3161,3188,3219,3254,3265,3272,3292,3299,3306,3333],{"type":37,"tag":418,"props":2717,"children":2718},{"class":420,"line":24},[2719,2724,2728,2733,2737,2741,2746,2750,2754,2758,2762,2767,2771,2775],{"type":37,"tag":418,"props":2720,"children":2721},{"style":424},[2722],{"type":43,"value":2723},"worker",{"type":37,"tag":418,"props":2725,"children":2726},{"style":430},[2727],{"type":43,"value":433},{"type":37,"tag":418,"props":2729,"children":2730},{"style":436},[2731],{"type":43,"value":2732},"on",{"type":37,"tag":418,"props":2734,"children":2735},{"style":424},[2736],{"type":43,"value":444},{"type":37,"tag":418,"props":2738,"children":2739},{"style":430},[2740],{"type":43,"value":449},{"type":37,"tag":418,"props":2742,"children":2743},{"style":452},[2744],{"type":43,"value":2745},"message",{"type":37,"tag":418,"props":2747,"children":2748},{"style":430},[2749],{"type":43,"value":449},{"type":37,"tag":418,"props":2751,"children":2752},{"style":430},[2753],{"type":43,"value":464},{"type":37,"tag":418,"props":2755,"children":2756},{"style":467},[2757],{"type":43,"value":470},{"type":37,"tag":418,"props":2759,"children":2760},{"style":430},[2761],{"type":43,"value":475},{"type":37,"tag":418,"props":2763,"children":2764},{"style":478},[2765],{"type":43,"value":2766},"msg",{"type":37,"tag":418,"props":2768,"children":2769},{"style":430},[2770],{"type":43,"value":495},{"type":37,"tag":418,"props":2772,"children":2773},{"style":467},[2774],{"type":43,"value":500},{"type":37,"tag":418,"props":2776,"children":2777},{"style":430},[2778],{"type":43,"value":505},{"type":37,"tag":418,"props":2780,"children":2781},{"class":420,"line":508},[2782,2786,2790,2795,2799,2803,2807,2811,2815,2819,2824,2828,2833,2837,2841,2845,2849,2853],{"type":37,"tag":418,"props":2783,"children":2784},{"style":467},[2785],{"type":43,"value":514},{"type":37,"tag":418,"props":2787,"children":2788},{"style":430},[2789],{"type":43,"value":787},{"type":37,"tag":418,"props":2791,"children":2792},{"style":424},[2793],{"type":43,"value":2794}," transactionId",{"type":37,"tag":418,"props":2796,"children":2797},{"style":430},[2798],{"type":43,"value":464},{"type":37,"tag":418,"props":2800,"children":2801},{"style":424},[2802],{"type":43,"value":1196},{"type":37,"tag":418,"props":2804,"children":2805},{"style":430},[2806],{"type":43,"value":464},{"type":37,"tag":418,"props":2808,"children":2809},{"style":424},[2810],{"type":43,"value":1430},{"type":37,"tag":418,"props":2812,"children":2813},{"style":430},[2814],{"type":43,"value":683},{"type":37,"tag":418,"props":2816,"children":2817},{"style":430},[2818],{"type":43,"value":524},{"type":37,"tag":418,"props":2820,"children":2821},{"style":424},[2822],{"type":43,"value":2823}," JSON",{"type":37,"tag":418,"props":2825,"children":2826},{"style":430},[2827],{"type":43,"value":433},{"type":37,"tag":418,"props":2829,"children":2830},{"style":436},[2831],{"type":43,"value":2832},"parse",{"type":37,"tag":418,"props":2834,"children":2835},{"style":541},[2836],{"type":43,"value":444},{"type":37,"tag":418,"props":2838,"children":2839},{"style":424},[2840],{"type":43,"value":2766},{"type":37,"tag":418,"props":2842,"children":2843},{"style":430},[2844],{"type":43,"value":433},{"type":37,"tag":418,"props":2846,"children":2847},{"style":424},[2848],{"type":43,"value":1248},{"type":37,"tag":418,"props":2850,"children":2851},{"style":541},[2852],{"type":43,"value":495},{"type":37,"tag":418,"props":2854,"children":2855},{"style":430},[2856],{"type":43,"value":567},{"type":37,"tag":418,"props":2858,"children":2859},{"class":420,"line":20},[2860],{"type":37,"tag":418,"props":2861,"children":2862},{"emptyLinePlaceholder":707},[2863],{"type":43,"value":710},{"type":37,"tag":418,"props":2865,"children":2866},{"class":420,"line":603},[2867,2871],{"type":37,"tag":418,"props":2868,"children":2869},{"style":573},[2870],{"type":43,"value":1959},{"type":37,"tag":418,"props":2872,"children":2873},{"style":430},[2874],{"type":43,"value":505},{"type":37,"tag":418,"props":2876,"children":2877},{"class":420,"line":694},[2878,2882,2886,2890,2894,2898,2902,2906,2910,2914,2918],{"type":37,"tag":418,"props":2879,"children":2880},{"style":573},[2881],{"type":43,"value":1040},{"type":37,"tag":418,"props":2883,"children":2884},{"style":424},[2885],{"type":43,"value":747},{"type":37,"tag":418,"props":2887,"children":2888},{"style":430},[2889],{"type":43,"value":433},{"type":37,"tag":418,"props":2891,"children":2892},{"style":436},[2893],{"type":43,"value":1001},{"type":37,"tag":418,"props":2895,"children":2896},{"style":541},[2897],{"type":43,"value":444},{"type":37,"tag":418,"props":2899,"children":2900},{"style":467},[2901],{"type":43,"value":1010},{"type":37,"tag":418,"props":2903,"children":2904},{"style":430},[2905],{"type":43,"value":475},{"type":37,"tag":418,"props":2907,"children":2908},{"style":478},[2909],{"type":43,"value":1019},{"type":37,"tag":418,"props":2911,"children":2912},{"style":430},[2913],{"type":43,"value":495},{"type":37,"tag":418,"props":2915,"children":2916},{"style":467},[2917],{"type":43,"value":500},{"type":37,"tag":418,"props":2919,"children":2920},{"style":430},[2921],{"type":43,"value":505},{"type":37,"tag":418,"props":2923,"children":2924},{"class":420,"line":703},[2925],{"type":37,"tag":418,"props":2926,"children":2927},{"style":717},[2928],{"type":43,"value":2929},"      \u002F\u002F Unique constraint on transactionId prevents duplicates\n",{"type":37,"tag":418,"props":2931,"children":2932},{"class":420,"line":713},[2933,2937,2941,2945,2950,2954,2958,2962,2966,2970,2974,2978,2983,2987,2991,2995,2999,3003,3007,3011,3015,3019,3023,3027],{"type":37,"tag":418,"props":2934,"children":2935},{"style":573},[2936],{"type":43,"value":2018},{"type":37,"tag":418,"props":2938,"children":2939},{"style":424},[2940],{"type":43,"value":1045},{"type":37,"tag":418,"props":2942,"children":2943},{"style":430},[2944],{"type":43,"value":433},{"type":37,"tag":418,"props":2946,"children":2947},{"style":424},[2948],{"type":43,"value":2949},"processedTransaction",{"type":37,"tag":418,"props":2951,"children":2952},{"style":430},[2953],{"type":43,"value":433},{"type":37,"tag":418,"props":2955,"children":2956},{"style":436},[2957],{"type":43,"value":1062},{"type":37,"tag":418,"props":2959,"children":2960},{"style":541},[2961],{"type":43,"value":444},{"type":37,"tag":418,"props":2963,"children":2964},{"style":430},[2965],{"type":43,"value":654},{"type":37,"tag":418,"props":2967,"children":2968},{"style":541},[2969],{"type":43,"value":1075},{"type":37,"tag":418,"props":2971,"children":2972},{"style":430},[2973],{"type":43,"value":664},{"type":37,"tag":418,"props":2975,"children":2976},{"style":430},[2977],{"type":43,"value":787},{"type":37,"tag":418,"props":2979,"children":2980},{"style":541},[2981],{"type":43,"value":2982}," id",{"type":37,"tag":418,"props":2984,"children":2985},{"style":430},[2986],{"type":43,"value":664},{"type":37,"tag":418,"props":2988,"children":2989},{"style":424},[2990],{"type":43,"value":2794},{"type":37,"tag":418,"props":2992,"children":2993},{"style":430},[2994],{"type":43,"value":464},{"type":37,"tag":418,"props":2996,"children":2997},{"style":541},[2998],{"type":43,"value":2089},{"type":37,"tag":418,"props":3000,"children":3001},{"style":430},[3002],{"type":43,"value":664},{"type":37,"tag":418,"props":3004,"children":3005},{"style":430},[3006],{"type":43,"value":2098},{"type":37,"tag":418,"props":3008,"children":3009},{"style":436},[3010],{"type":43,"value":2103},{"type":37,"tag":418,"props":3012,"children":3013},{"style":541},[3014],{"type":43,"value":2108},{"type":37,"tag":418,"props":3016,"children":3017},{"style":430},[3018],{"type":43,"value":1784},{"type":37,"tag":418,"props":3020,"children":3021},{"style":430},[3022],{"type":43,"value":683},{"type":37,"tag":418,"props":3024,"children":3025},{"style":541},[3026],{"type":43,"value":495},{"type":37,"tag":418,"props":3028,"children":3029},{"style":430},[3030],{"type":43,"value":567},{"type":37,"tag":418,"props":3032,"children":3033},{"class":420,"line":723},[3034,3038,3042,3046,3051,3055,3059,3063,3067,3071,3075,3079,3083,3088,3092,3096,3100,3105,3109,3113,3118,3122,3126,3130,3134,3138,3142],{"type":37,"tag":418,"props":3035,"children":3036},{"style":573},[3037],{"type":43,"value":2018},{"type":37,"tag":418,"props":3039,"children":3040},{"style":424},[3041],{"type":43,"value":1045},{"type":37,"tag":418,"props":3043,"children":3044},{"style":430},[3045],{"type":43,"value":433},{"type":37,"tag":418,"props":3047,"children":3048},{"style":424},[3049],{"type":43,"value":3050},"account",{"type":37,"tag":418,"props":3052,"children":3053},{"style":430},[3054],{"type":43,"value":433},{"type":37,"tag":418,"props":3056,"children":3057},{"style":436},[3058],{"type":43,"value":1580},{"type":37,"tag":418,"props":3060,"children":3061},{"style":541},[3062],{"type":43,"value":444},{"type":37,"tag":418,"props":3064,"children":3065},{"style":430},[3066],{"type":43,"value":654},{"type":37,"tag":418,"props":3068,"children":3069},{"style":541},[3070],{"type":43,"value":778},{"type":37,"tag":418,"props":3072,"children":3073},{"style":430},[3074],{"type":43,"value":664},{"type":37,"tag":418,"props":3076,"children":3077},{"style":430},[3078],{"type":43,"value":787},{"type":37,"tag":418,"props":3080,"children":3081},{"style":424},[3082],{"type":43,"value":1196},{"type":37,"tag":418,"props":3084,"children":3085},{"style":430},[3086],{"type":43,"value":3087}," },",{"type":37,"tag":418,"props":3089,"children":3090},{"style":541},[3091],{"type":43,"value":1075},{"type":37,"tag":418,"props":3093,"children":3094},{"style":430},[3095],{"type":43,"value":664},{"type":37,"tag":418,"props":3097,"children":3098},{"style":430},[3099],{"type":43,"value":787},{"type":37,"tag":418,"props":3101,"children":3102},{"style":541},[3103],{"type":43,"value":3104}," balance",{"type":37,"tag":418,"props":3106,"children":3107},{"style":430},[3108],{"type":43,"value":664},{"type":37,"tag":418,"props":3110,"children":3111},{"style":430},[3112],{"type":43,"value":787},{"type":37,"tag":418,"props":3114,"children":3115},{"style":541},[3116],{"type":43,"value":3117}," increment",{"type":37,"tag":418,"props":3119,"children":3120},{"style":430},[3121],{"type":43,"value":664},{"type":37,"tag":418,"props":3123,"children":3124},{"style":424},[3125],{"type":43,"value":1430},{"type":37,"tag":418,"props":3127,"children":3128},{"style":430},[3129],{"type":43,"value":683},{"type":37,"tag":418,"props":3131,"children":3132},{"style":430},[3133],{"type":43,"value":683},{"type":37,"tag":418,"props":3135,"children":3136},{"style":430},[3137],{"type":43,"value":683},{"type":37,"tag":418,"props":3139,"children":3140},{"style":541},[3141],{"type":43,"value":495},{"type":37,"tag":418,"props":3143,"children":3144},{"style":430},[3145],{"type":43,"value":567},{"type":37,"tag":418,"props":3147,"children":3148},{"class":420,"line":819},[3149,3153,3157],{"type":37,"tag":418,"props":3150,"children":3151},{"style":430},[3152],{"type":43,"value":1305},{"type":37,"tag":418,"props":3154,"children":3155},{"style":541},[3156],{"type":43,"value":495},{"type":37,"tag":418,"props":3158,"children":3159},{"style":430},[3160],{"type":43,"value":567},{"type":37,"tag":418,"props":3162,"children":3163},{"class":420,"line":871},[3164,3168,3172,3176,3180,3184],{"type":37,"tag":418,"props":3165,"children":3166},{"style":430},[3167],{"type":43,"value":1322},{"type":37,"tag":418,"props":3169,"children":3170},{"style":573},[3171],{"type":43,"value":2362},{"type":37,"tag":418,"props":3173,"children":3174},{"style":541},[3175],{"type":43,"value":475},{"type":37,"tag":418,"props":3177,"children":3178},{"style":424},[3179],{"type":43,"value":2371},{"type":37,"tag":418,"props":3181,"children":3182},{"style":541},[3183],{"type":43,"value":595},{"type":37,"tag":418,"props":3185,"children":3186},{"style":430},[3187],{"type":43,"value":600},{"type":37,"tag":418,"props":3189,"children":3190},{"class":420,"line":945},[3191,3195,3199,3203,3207,3211,3215],{"type":37,"tag":418,"props":3192,"children":3193},{"style":573},[3194],{"type":43,"value":2387},{"type":37,"tag":418,"props":3196,"children":3197},{"style":541},[3198],{"type":43,"value":475},{"type":37,"tag":418,"props":3200,"children":3201},{"style":436},[3202],{"type":43,"value":2396},{"type":37,"tag":418,"props":3204,"children":3205},{"style":541},[3206],{"type":43,"value":444},{"type":37,"tag":418,"props":3208,"children":3209},{"style":424},[3210],{"type":43,"value":2371},{"type":37,"tag":418,"props":3212,"children":3213},{"style":541},[3214],{"type":43,"value":2409},{"type":37,"tag":418,"props":3216,"children":3217},{"style":430},[3218],{"type":43,"value":600},{"type":37,"tag":418,"props":3220,"children":3221},{"class":420,"line":953},[3222,3226,3231,3235,3240,3245,3249],{"type":37,"tag":418,"props":3223,"children":3224},{"style":573},[3225],{"type":43,"value":2018},{"type":37,"tag":418,"props":3227,"children":3228},{"style":424},[3229],{"type":43,"value":3230}," msg",{"type":37,"tag":418,"props":3232,"children":3233},{"style":430},[3234],{"type":43,"value":433},{"type":37,"tag":418,"props":3236,"children":3237},{"style":436},[3238],{"type":43,"value":3239},"ack",{"type":37,"tag":418,"props":3241,"children":3242},{"style":541},[3243],{"type":43,"value":3244},"()",{"type":37,"tag":418,"props":3246,"children":3247},{"style":430},[3248],{"type":43,"value":2469},{"type":37,"tag":418,"props":3250,"children":3251},{"style":717},[3252],{"type":43,"value":3253}," \u002F\u002F Already processed -- ack and move on\n",{"type":37,"tag":418,"props":3255,"children":3256},{"class":420,"line":961},[3257,3261],{"type":37,"tag":418,"props":3258,"children":3259},{"style":573},[3260],{"type":43,"value":2421},{"type":37,"tag":418,"props":3262,"children":3263},{"style":430},[3264],{"type":43,"value":567},{"type":37,"tag":418,"props":3266,"children":3267},{"class":420,"line":970},[3268],{"type":37,"tag":418,"props":3269,"children":3270},{"style":430},[3271],{"type":43,"value":2482},{"type":37,"tag":418,"props":3273,"children":3274},{"class":420,"line":1034},[3275,3279,3283,3287],{"type":37,"tag":418,"props":3276,"children":3277},{"style":573},[3278],{"type":43,"value":2490},{"type":37,"tag":418,"props":3280,"children":3281},{"style":424},[3282],{"type":43,"value":659},{"type":37,"tag":418,"props":3284,"children":3285},{"style":430},[3286],{"type":43,"value":2469},{"type":37,"tag":418,"props":3288,"children":3289},{"style":717},[3290],{"type":43,"value":3291}," \u002F\u002F Real error -- don't ack, let queue redeliver\n",{"type":37,"tag":418,"props":3293,"children":3294},{"class":420,"line":1140},[3295],{"type":37,"tag":418,"props":3296,"children":3297},{"style":430},[3298],{"type":43,"value":700},{"type":37,"tag":418,"props":3300,"children":3301},{"class":420,"line":1177},[3302],{"type":37,"tag":418,"props":3303,"children":3304},{"emptyLinePlaceholder":707},[3305],{"type":43,"value":710},{"type":37,"tag":418,"props":3307,"children":3308},{"class":420,"line":1299},[3309,3313,3317,3321,3325,3329],{"type":37,"tag":418,"props":3310,"children":3311},{"style":573},[3312],{"type":43,"value":1356},{"type":37,"tag":418,"props":3314,"children":3315},{"style":424},[3316],{"type":43,"value":3230},{"type":37,"tag":418,"props":3318,"children":3319},{"style":430},[3320],{"type":43,"value":433},{"type":37,"tag":418,"props":3322,"children":3323},{"style":436},[3324],{"type":43,"value":3239},{"type":37,"tag":418,"props":3326,"children":3327},{"style":541},[3328],{"type":43,"value":3244},{"type":37,"tag":418,"props":3330,"children":3331},{"style":430},[3332],{"type":43,"value":567},{"type":37,"tag":418,"props":3334,"children":3335},{"class":420,"line":1316},[3336,3340,3344],{"type":37,"tag":418,"props":3337,"children":3338},{"style":430},[3339],{"type":43,"value":1784},{"type":37,"tag":418,"props":3341,"children":3342},{"style":424},[3343],{"type":43,"value":495},{"type":37,"tag":418,"props":3345,"children":3346},{"style":430},[3347],{"type":43,"value":567},{"type":37,"tag":395,"props":3349,"children":3351},{"id":3350},"natural-idempotency-via-upsert",[3352],{"type":43,"value":3353},"Natural idempotency via upsert",{"type":37,"tag":46,"props":3355,"children":3356},{},[3357],{"type":43,"value":3358},"When possible, design the operation so repeating it converges on the same state -- upsert, or SET rather than INCREMENT.",{"type":37,"tag":407,"props":3360,"children":3362},{"className":409,"code":3361,"language":411,"meta":412,"style":412},"\u002F\u002F Same result whether it runs once or five times\nasync function setUserPreference(userId: string, key: string, value: string) {\n  await db.userPreference.upsert({\n    where: { userId_key: { userId, key } },\n    create: { userId, key, value },\n    update: { value },\n  });\n}\n",[3363],{"type":37,"tag":145,"props":3364,"children":3365},{"__ignoreMap":412},[3366,3374,3450,3487,3535,3575,3599,3614],{"type":37,"tag":418,"props":3367,"children":3368},{"class":420,"line":24},[3369],{"type":37,"tag":418,"props":3370,"children":3371},{"style":717},[3372],{"type":43,"value":3373},"\u002F\u002F Same result whether it runs once or five times\n",{"type":37,"tag":418,"props":3375,"children":3376},{"class":420,"line":508},[3377,3381,3386,3391,3395,3399,3403,3409,3413,3417,3421,3425,3429,3434,3438,3442,3446],{"type":37,"tag":418,"props":3378,"children":3379},{"style":467},[3380],{"type":43,"value":1010},{"type":37,"tag":418,"props":3382,"children":3383},{"style":467},[3384],{"type":43,"value":3385}," function",{"type":37,"tag":418,"props":3387,"children":3388},{"style":436},[3389],{"type":43,"value":3390}," setUserPreference",{"type":37,"tag":418,"props":3392,"children":3393},{"style":430},[3394],{"type":43,"value":444},{"type":37,"tag":418,"props":3396,"children":3397},{"style":478},[3398],{"type":43,"value":2613},{"type":37,"tag":418,"props":3400,"children":3401},{"style":430},[3402],{"type":43,"value":664},{"type":37,"tag":418,"props":3404,"children":3406},{"style":3405},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[3407],{"type":43,"value":3408}," string",{"type":37,"tag":418,"props":3410,"children":3411},{"style":430},[3412],{"type":43,"value":464},{"type":37,"tag":418,"props":3414,"children":3415},{"style":478},[3416],{"type":43,"value":792},{"type":37,"tag":418,"props":3418,"children":3419},{"style":430},[3420],{"type":43,"value":664},{"type":37,"tag":418,"props":3422,"children":3423},{"style":3405},[3424],{"type":43,"value":3408},{"type":37,"tag":418,"props":3426,"children":3427},{"style":430},[3428],{"type":43,"value":464},{"type":37,"tag":418,"props":3430,"children":3431},{"style":478},[3432],{"type":43,"value":3433}," value",{"type":37,"tag":418,"props":3435,"children":3436},{"style":430},[3437],{"type":43,"value":664},{"type":37,"tag":418,"props":3439,"children":3440},{"style":3405},[3441],{"type":43,"value":3408},{"type":37,"tag":418,"props":3443,"children":3444},{"style":430},[3445],{"type":43,"value":495},{"type":37,"tag":418,"props":3447,"children":3448},{"style":430},[3449],{"type":43,"value":505},{"type":37,"tag":418,"props":3451,"children":3452},{"class":420,"line":20},[3453,3457,3461,3465,3470,3474,3479,3483],{"type":37,"tag":418,"props":3454,"children":3455},{"style":573},[3456],{"type":43,"value":1356},{"type":37,"tag":418,"props":3458,"children":3459},{"style":424},[3460],{"type":43,"value":747},{"type":37,"tag":418,"props":3462,"children":3463},{"style":430},[3464],{"type":43,"value":433},{"type":37,"tag":418,"props":3466,"children":3467},{"style":424},[3468],{"type":43,"value":3469},"userPreference",{"type":37,"tag":418,"props":3471,"children":3472},{"style":430},[3473],{"type":43,"value":433},{"type":37,"tag":418,"props":3475,"children":3476},{"style":436},[3477],{"type":43,"value":3478},"upsert",{"type":37,"tag":418,"props":3480,"children":3481},{"style":541},[3482],{"type":43,"value":444},{"type":37,"tag":418,"props":3484,"children":3485},{"style":430},[3486],{"type":43,"value":600},{"type":37,"tag":418,"props":3488,"children":3489},{"class":420,"line":603},[3490,3494,3498,3502,3507,3511,3515,3519,3523,3527,3531],{"type":37,"tag":418,"props":3491,"children":3492},{"style":541},[3493],{"type":43,"value":1597},{"type":37,"tag":418,"props":3495,"children":3496},{"style":430},[3497],{"type":43,"value":664},{"type":37,"tag":418,"props":3499,"children":3500},{"style":430},[3501],{"type":43,"value":787},{"type":37,"tag":418,"props":3503,"children":3504},{"style":541},[3505],{"type":43,"value":3506}," userId_key",{"type":37,"tag":418,"props":3508,"children":3509},{"style":430},[3510],{"type":43,"value":664},{"type":37,"tag":418,"props":3512,"children":3513},{"style":430},[3514],{"type":43,"value":787},{"type":37,"tag":418,"props":3516,"children":3517},{"style":424},[3518],{"type":43,"value":1196},{"type":37,"tag":418,"props":3520,"children":3521},{"style":430},[3522],{"type":43,"value":464},{"type":37,"tag":418,"props":3524,"children":3525},{"style":424},[3526],{"type":43,"value":792},{"type":37,"tag":418,"props":3528,"children":3529},{"style":430},[3530],{"type":43,"value":683},{"type":37,"tag":418,"props":3532,"children":3533},{"style":430},[3534],{"type":43,"value":1296},{"type":37,"tag":418,"props":3536,"children":3537},{"class":420,"line":694},[3538,3543,3547,3551,3555,3559,3563,3567,3571],{"type":37,"tag":418,"props":3539,"children":3540},{"style":541},[3541],{"type":43,"value":3542},"    create",{"type":37,"tag":418,"props":3544,"children":3545},{"style":430},[3546],{"type":43,"value":664},{"type":37,"tag":418,"props":3548,"children":3549},{"style":430},[3550],{"type":43,"value":787},{"type":37,"tag":418,"props":3552,"children":3553},{"style":424},[3554],{"type":43,"value":1196},{"type":37,"tag":418,"props":3556,"children":3557},{"style":430},[3558],{"type":43,"value":464},{"type":37,"tag":418,"props":3560,"children":3561},{"style":424},[3562],{"type":43,"value":792},{"type":37,"tag":418,"props":3564,"children":3565},{"style":430},[3566],{"type":43,"value":464},{"type":37,"tag":418,"props":3568,"children":3569},{"style":424},[3570],{"type":43,"value":3433},{"type":37,"tag":418,"props":3572,"children":3573},{"style":430},[3574],{"type":43,"value":1296},{"type":37,"tag":418,"props":3576,"children":3577},{"class":420,"line":703},[3578,3583,3587,3591,3595],{"type":37,"tag":418,"props":3579,"children":3580},{"style":541},[3581],{"type":43,"value":3582},"    update",{"type":37,"tag":418,"props":3584,"children":3585},{"style":430},[3586],{"type":43,"value":664},{"type":37,"tag":418,"props":3588,"children":3589},{"style":430},[3590],{"type":43,"value":787},{"type":37,"tag":418,"props":3592,"children":3593},{"style":424},[3594],{"type":43,"value":3433},{"type":37,"tag":418,"props":3596,"children":3597},{"style":430},[3598],{"type":43,"value":1296},{"type":37,"tag":418,"props":3600,"children":3601},{"class":420,"line":713},[3602,3606,3610],{"type":37,"tag":418,"props":3603,"children":3604},{"style":430},[3605],{"type":43,"value":1322},{"type":37,"tag":418,"props":3607,"children":3608},{"style":541},[3609],{"type":43,"value":495},{"type":37,"tag":418,"props":3611,"children":3612},{"style":430},[3613],{"type":43,"value":567},{"type":37,"tag":418,"props":3615,"children":3616},{"class":420,"line":723},[3617],{"type":37,"tag":418,"props":3618,"children":3619},{"style":430},[3620],{"type":43,"value":3621},"}\n",{"type":37,"tag":395,"props":3623,"children":3625},{"id":3624},"making-external-api-calls-idempotent",[3626],{"type":43,"value":3627},"Making external API calls idempotent",{"type":37,"tag":46,"props":3629,"children":3630},{},[3631],{"type":43,"value":3632},"Most payment\u002Fcommunication APIs support idempotency keys -- always pass them.",{"type":37,"tag":407,"props":3634,"children":3636},{"className":409,"code":3635,"language":411,"meta":412,"style":412},"await stripe.paymentIntents.create(\n  { customer: customerId, amount, currency: \"usd\" },\n  { idempotencyKey: `order-${orderId}-charge` }\n);\n\u002F\u002F Twilio: unique message SID or your own dedup. SendGrid: custom unique args. AWS SES: MessageDeduplicationId (FIFO).\n",[3637],{"type":37,"tag":145,"props":3638,"children":3639},{"__ignoreMap":412},[3640,3672,3729,3780,3791],{"type":37,"tag":418,"props":3641,"children":3642},{"class":420,"line":24},[3643,3648,3652,3656,3660,3664,3668],{"type":37,"tag":418,"props":3644,"children":3645},{"style":573},[3646],{"type":43,"value":3647},"await",{"type":37,"tag":418,"props":3649,"children":3650},{"style":424},[3651],{"type":43,"value":1361},{"type":37,"tag":418,"props":3653,"children":3654},{"style":430},[3655],{"type":43,"value":433},{"type":37,"tag":418,"props":3657,"children":3658},{"style":424},[3659],{"type":43,"value":1370},{"type":37,"tag":418,"props":3661,"children":3662},{"style":430},[3663],{"type":43,"value":433},{"type":37,"tag":418,"props":3665,"children":3666},{"style":436},[3667],{"type":43,"value":1062},{"type":37,"tag":418,"props":3669,"children":3670},{"style":424},[3671],{"type":43,"value":1383},{"type":37,"tag":418,"props":3673,"children":3674},{"class":420,"line":508},[3675,3680,3684,3688,3693,3697,3701,3705,3709,3713,3717,3721,3725],{"type":37,"tag":418,"props":3676,"children":3677},{"style":430},[3678],{"type":43,"value":3679},"  {",{"type":37,"tag":418,"props":3681,"children":3682},{"style":541},[3683],{"type":43,"value":1397},{"type":37,"tag":418,"props":3685,"children":3686},{"style":430},[3687],{"type":43,"value":664},{"type":37,"tag":418,"props":3689,"children":3690},{"style":424},[3691],{"type":43,"value":3692}," customerId",{"type":37,"tag":418,"props":3694,"children":3695},{"style":430},[3696],{"type":43,"value":464},{"type":37,"tag":418,"props":3698,"children":3699},{"style":424},[3700],{"type":43,"value":1430},{"type":37,"tag":418,"props":3702,"children":3703},{"style":430},[3704],{"type":43,"value":464},{"type":37,"tag":418,"props":3706,"children":3707},{"style":541},[3708],{"type":43,"value":1455},{"type":37,"tag":418,"props":3710,"children":3711},{"style":430},[3712],{"type":43,"value":664},{"type":37,"tag":418,"props":3714,"children":3715},{"style":430},[3716],{"type":43,"value":669},{"type":37,"tag":418,"props":3718,"children":3719},{"style":452},[3720],{"type":43,"value":1468},{"type":37,"tag":418,"props":3722,"children":3723},{"style":430},[3724],{"type":43,"value":449},{"type":37,"tag":418,"props":3726,"children":3727},{"style":430},[3728],{"type":43,"value":1296},{"type":37,"tag":418,"props":3730,"children":3731},{"class":420,"line":20},[3732,3736,3740,3744,3748,3753,3757,3762,3766,3771,3776],{"type":37,"tag":418,"props":3733,"children":3734},{"style":430},[3735],{"type":43,"value":3679},{"type":37,"tag":418,"props":3737,"children":3738},{"style":541},[3739],{"type":43,"value":519},{"type":37,"tag":418,"props":3741,"children":3742},{"style":430},[3743],{"type":43,"value":664},{"type":37,"tag":418,"props":3745,"children":3746},{"style":430},[3747],{"type":43,"value":1497},{"type":37,"tag":418,"props":3749,"children":3750},{"style":452},[3751],{"type":43,"value":3752},"order-",{"type":37,"tag":418,"props":3754,"children":3755},{"style":430},[3756],{"type":43,"value":1507},{"type":37,"tag":418,"props":3758,"children":3759},{"style":424},[3760],{"type":43,"value":3761},"orderId",{"type":37,"tag":418,"props":3763,"children":3764},{"style":430},[3765],{"type":43,"value":1784},{"type":37,"tag":418,"props":3767,"children":3768},{"style":452},[3769],{"type":43,"value":3770},"-charge",{"type":37,"tag":418,"props":3772,"children":3773},{"style":430},[3774],{"type":43,"value":3775},"`",{"type":37,"tag":418,"props":3777,"children":3778},{"style":430},[3779],{"type":43,"value":1521},{"type":37,"tag":418,"props":3781,"children":3782},{"class":420,"line":603},[3783,3787],{"type":37,"tag":418,"props":3784,"children":3785},{"style":424},[3786],{"type":43,"value":495},{"type":37,"tag":418,"props":3788,"children":3789},{"style":430},[3790],{"type":43,"value":567},{"type":37,"tag":418,"props":3792,"children":3793},{"class":420,"line":694},[3794],{"type":37,"tag":418,"props":3795,"children":3796},{"style":717},[3797],{"type":43,"value":3798},"\u002F\u002F Twilio: unique message SID or your own dedup. SendGrid: custom unique args. AWS SES: MessageDeduplicationId (FIFO).\n",{"type":37,"tag":46,"props":3800,"children":3801},{},[3802],{"type":43,"value":3803},"If the API has no idempotency-key support, track the call yourself:",{"type":37,"tag":407,"props":3805,"children":3807},{"className":409,"code":3806,"language":411,"meta":412,"style":412},"async function sendWelcomeEmail(userId: string) {\n  const sent = await db.sentEmail.findUnique({\n    where: { userId_template: { userId, template: \"welcome\" } },\n  });\n  if (sent) return; \u002F\u002F Already sent\n\n  await emailService.send({ to: userId, template: \"welcome\" });\n  await db.sentEmail.create({ data: { userId, template: \"welcome\", sentAt: new Date() } });\n}\n",[3808],{"type":37,"tag":145,"props":3809,"children":3810},{"__ignoreMap":412},[3811,3851,3900,3966,3981,4015,4022,4100,4216],{"type":37,"tag":418,"props":3812,"children":3813},{"class":420,"line":24},[3814,3818,3822,3827,3831,3835,3839,3843,3847],{"type":37,"tag":418,"props":3815,"children":3816},{"style":467},[3817],{"type":43,"value":1010},{"type":37,"tag":418,"props":3819,"children":3820},{"style":467},[3821],{"type":43,"value":3385},{"type":37,"tag":418,"props":3823,"children":3824},{"style":436},[3825],{"type":43,"value":3826}," sendWelcomeEmail",{"type":37,"tag":418,"props":3828,"children":3829},{"style":430},[3830],{"type":43,"value":444},{"type":37,"tag":418,"props":3832,"children":3833},{"style":478},[3834],{"type":43,"value":2613},{"type":37,"tag":418,"props":3836,"children":3837},{"style":430},[3838],{"type":43,"value":664},{"type":37,"tag":418,"props":3840,"children":3841},{"style":3405},[3842],{"type":43,"value":3408},{"type":37,"tag":418,"props":3844,"children":3845},{"style":430},[3846],{"type":43,"value":495},{"type":37,"tag":418,"props":3848,"children":3849},{"style":430},[3850],{"type":43,"value":505},{"type":37,"tag":418,"props":3852,"children":3853},{"class":420,"line":508},[3854,3858,3863,3867,3871,3875,3879,3884,3888,3892,3896],{"type":37,"tag":418,"props":3855,"children":3856},{"style":467},[3857],{"type":43,"value":514},{"type":37,"tag":418,"props":3859,"children":3860},{"style":424},[3861],{"type":43,"value":3862}," sent",{"type":37,"tag":418,"props":3864,"children":3865},{"style":430},[3866],{"type":43,"value":524},{"type":37,"tag":418,"props":3868,"children":3869},{"style":573},[3870],{"type":43,"value":742},{"type":37,"tag":418,"props":3872,"children":3873},{"style":424},[3874],{"type":43,"value":747},{"type":37,"tag":418,"props":3876,"children":3877},{"style":430},[3878],{"type":43,"value":433},{"type":37,"tag":418,"props":3880,"children":3881},{"style":424},[3882],{"type":43,"value":3883},"sentEmail",{"type":37,"tag":418,"props":3885,"children":3886},{"style":430},[3887],{"type":43,"value":433},{"type":37,"tag":418,"props":3889,"children":3890},{"style":436},[3891],{"type":43,"value":765},{"type":37,"tag":418,"props":3893,"children":3894},{"style":541},[3895],{"type":43,"value":444},{"type":37,"tag":418,"props":3897,"children":3898},{"style":430},[3899],{"type":43,"value":600},{"type":37,"tag":418,"props":3901,"children":3902},{"class":420,"line":20},[3903,3907,3911,3915,3920,3924,3928,3932,3936,3941,3945,3949,3954,3958,3962],{"type":37,"tag":418,"props":3904,"children":3905},{"style":541},[3906],{"type":43,"value":1597},{"type":37,"tag":418,"props":3908,"children":3909},{"style":430},[3910],{"type":43,"value":664},{"type":37,"tag":418,"props":3912,"children":3913},{"style":430},[3914],{"type":43,"value":787},{"type":37,"tag":418,"props":3916,"children":3917},{"style":541},[3918],{"type":43,"value":3919}," userId_template",{"type":37,"tag":418,"props":3921,"children":3922},{"style":430},[3923],{"type":43,"value":664},{"type":37,"tag":418,"props":3925,"children":3926},{"style":430},[3927],{"type":43,"value":787},{"type":37,"tag":418,"props":3929,"children":3930},{"style":424},[3931],{"type":43,"value":1196},{"type":37,"tag":418,"props":3933,"children":3934},{"style":430},[3935],{"type":43,"value":464},{"type":37,"tag":418,"props":3937,"children":3938},{"style":541},[3939],{"type":43,"value":3940}," template",{"type":37,"tag":418,"props":3942,"children":3943},{"style":430},[3944],{"type":43,"value":664},{"type":37,"tag":418,"props":3946,"children":3947},{"style":430},[3948],{"type":43,"value":669},{"type":37,"tag":418,"props":3950,"children":3951},{"style":452},[3952],{"type":43,"value":3953},"welcome",{"type":37,"tag":418,"props":3955,"children":3956},{"style":430},[3957],{"type":43,"value":449},{"type":37,"tag":418,"props":3959,"children":3960},{"style":430},[3961],{"type":43,"value":683},{"type":37,"tag":418,"props":3963,"children":3964},{"style":430},[3965],{"type":43,"value":1296},{"type":37,"tag":418,"props":3967,"children":3968},{"class":420,"line":603},[3969,3973,3977],{"type":37,"tag":418,"props":3970,"children":3971},{"style":430},[3972],{"type":43,"value":1322},{"type":37,"tag":418,"props":3974,"children":3975},{"style":541},[3976],{"type":43,"value":495},{"type":37,"tag":418,"props":3978,"children":3979},{"style":430},[3980],{"type":43,"value":567},{"type":37,"tag":418,"props":3982,"children":3983},{"class":420,"line":694},[3984,3988,3992,3997,4001,4006,4010],{"type":37,"tag":418,"props":3985,"children":3986},{"style":573},[3987],{"type":43,"value":576},{"type":37,"tag":418,"props":3989,"children":3990},{"style":541},[3991],{"type":43,"value":475},{"type":37,"tag":418,"props":3993,"children":3994},{"style":424},[3995],{"type":43,"value":3996},"sent",{"type":37,"tag":418,"props":3998,"children":3999},{"style":541},[4000],{"type":43,"value":595},{"type":37,"tag":418,"props":4002,"children":4003},{"style":573},[4004],{"type":43,"value":4005},"return",{"type":37,"tag":418,"props":4007,"children":4008},{"style":430},[4009],{"type":43,"value":2469},{"type":37,"tag":418,"props":4011,"children":4012},{"style":717},[4013],{"type":43,"value":4014}," \u002F\u002F Already sent\n",{"type":37,"tag":418,"props":4016,"children":4017},{"class":420,"line":703},[4018],{"type":37,"tag":418,"props":4019,"children":4020},{"emptyLinePlaceholder":707},[4021],{"type":43,"value":710},{"type":37,"tag":418,"props":4023,"children":4024},{"class":420,"line":713},[4025,4029,4034,4038,4043,4047,4051,4056,4060,4064,4068,4072,4076,4080,4084,4088,4092,4096],{"type":37,"tag":418,"props":4026,"children":4027},{"style":573},[4028],{"type":43,"value":1356},{"type":37,"tag":418,"props":4030,"children":4031},{"style":424},[4032],{"type":43,"value":4033}," emailService",{"type":37,"tag":418,"props":4035,"children":4036},{"style":430},[4037],{"type":43,"value":433},{"type":37,"tag":418,"props":4039,"children":4040},{"style":436},[4041],{"type":43,"value":4042},"send",{"type":37,"tag":418,"props":4044,"children":4045},{"style":541},[4046],{"type":43,"value":444},{"type":37,"tag":418,"props":4048,"children":4049},{"style":430},[4050],{"type":43,"value":654},{"type":37,"tag":418,"props":4052,"children":4053},{"style":541},[4054],{"type":43,"value":4055}," to",{"type":37,"tag":418,"props":4057,"children":4058},{"style":430},[4059],{"type":43,"value":664},{"type":37,"tag":418,"props":4061,"children":4062},{"style":424},[4063],{"type":43,"value":1196},{"type":37,"tag":418,"props":4065,"children":4066},{"style":430},[4067],{"type":43,"value":464},{"type":37,"tag":418,"props":4069,"children":4070},{"style":541},[4071],{"type":43,"value":3940},{"type":37,"tag":418,"props":4073,"children":4074},{"style":430},[4075],{"type":43,"value":664},{"type":37,"tag":418,"props":4077,"children":4078},{"style":430},[4079],{"type":43,"value":669},{"type":37,"tag":418,"props":4081,"children":4082},{"style":452},[4083],{"type":43,"value":3953},{"type":37,"tag":418,"props":4085,"children":4086},{"style":430},[4087],{"type":43,"value":449},{"type":37,"tag":418,"props":4089,"children":4090},{"style":430},[4091],{"type":43,"value":683},{"type":37,"tag":418,"props":4093,"children":4094},{"style":541},[4095],{"type":43,"value":495},{"type":37,"tag":418,"props":4097,"children":4098},{"style":430},[4099],{"type":43,"value":567},{"type":37,"tag":418,"props":4101,"children":4102},{"class":420,"line":723},[4103,4107,4111,4115,4119,4123,4127,4131,4135,4139,4143,4147,4151,4155,4159,4163,4167,4171,4175,4179,4184,4188,4192,4196,4200,4204,4208,4212],{"type":37,"tag":418,"props":4104,"children":4105},{"style":573},[4106],{"type":43,"value":1356},{"type":37,"tag":418,"props":4108,"children":4109},{"style":424},[4110],{"type":43,"value":747},{"type":37,"tag":418,"props":4112,"children":4113},{"style":430},[4114],{"type":43,"value":433},{"type":37,"tag":418,"props":4116,"children":4117},{"style":424},[4118],{"type":43,"value":3883},{"type":37,"tag":418,"props":4120,"children":4121},{"style":430},[4122],{"type":43,"value":433},{"type":37,"tag":418,"props":4124,"children":4125},{"style":436},[4126],{"type":43,"value":1062},{"type":37,"tag":418,"props":4128,"children":4129},{"style":541},[4130],{"type":43,"value":444},{"type":37,"tag":418,"props":4132,"children":4133},{"style":430},[4134],{"type":43,"value":654},{"type":37,"tag":418,"props":4136,"children":4137},{"style":541},[4138],{"type":43,"value":1075},{"type":37,"tag":418,"props":4140,"children":4141},{"style":430},[4142],{"type":43,"value":664},{"type":37,"tag":418,"props":4144,"children":4145},{"style":430},[4146],{"type":43,"value":787},{"type":37,"tag":418,"props":4148,"children":4149},{"style":424},[4150],{"type":43,"value":1196},{"type":37,"tag":418,"props":4152,"children":4153},{"style":430},[4154],{"type":43,"value":464},{"type":37,"tag":418,"props":4156,"children":4157},{"style":541},[4158],{"type":43,"value":3940},{"type":37,"tag":418,"props":4160,"children":4161},{"style":430},[4162],{"type":43,"value":664},{"type":37,"tag":418,"props":4164,"children":4165},{"style":430},[4166],{"type":43,"value":669},{"type":37,"tag":418,"props":4168,"children":4169},{"style":452},[4170],{"type":43,"value":3953},{"type":37,"tag":418,"props":4172,"children":4173},{"style":430},[4174],{"type":43,"value":449},{"type":37,"tag":418,"props":4176,"children":4177},{"style":430},[4178],{"type":43,"value":464},{"type":37,"tag":418,"props":4180,"children":4181},{"style":541},[4182],{"type":43,"value":4183}," sentAt",{"type":37,"tag":418,"props":4185,"children":4186},{"style":430},[4187],{"type":43,"value":664},{"type":37,"tag":418,"props":4189,"children":4190},{"style":430},[4191],{"type":43,"value":2098},{"type":37,"tag":418,"props":4193,"children":4194},{"style":436},[4195],{"type":43,"value":2103},{"type":37,"tag":418,"props":4197,"children":4198},{"style":541},[4199],{"type":43,"value":2108},{"type":37,"tag":418,"props":4201,"children":4202},{"style":430},[4203],{"type":43,"value":1784},{"type":37,"tag":418,"props":4205,"children":4206},{"style":430},[4207],{"type":43,"value":683},{"type":37,"tag":418,"props":4209,"children":4210},{"style":541},[4211],{"type":43,"value":495},{"type":37,"tag":418,"props":4213,"children":4214},{"style":430},[4215],{"type":43,"value":567},{"type":37,"tag":418,"props":4217,"children":4218},{"class":420,"line":819},[4219],{"type":37,"tag":418,"props":4220,"children":4221},{"style":430},[4222],{"type":43,"value":3621},{"type":37,"tag":58,"props":4224,"children":4226},{"id":4225},"anti-patterns",[4227],{"type":43,"value":4228},"Anti-Patterns",{"type":37,"tag":407,"props":4230,"children":4232},{"className":409,"code":4231,"language":411,"meta":412,"style":412},"\u002F\u002F Dangerous: retry wrapping a non-idempotent call\nawait retry(() => stripe.paymentIntents.create({ amount, customer }), { retries: 3 });\n\u002F\u002F First call succeeds, response lost, retry creates a SECOND charge. Fix: pass idempotencyKey to Stripe.\n\n\u002F\u002F Dangerous: POST handler with no dedup -- double-click = two orders, two charges\napp.post(\"\u002Fapi\u002Forders\", async (req, res) => {\n  const order = await db.order.create({ data: req.body });\n  await chargeCustomer(order.total);\n  res.status(201).json(order);\n});\n\u002F\u002F Fix: require and check Idempotency-Key header.\n\n\u002F\u002F Dangerous: queue consumer with INCREMENT -- SQS delivers twice = balance incremented twice\nworker.on(\"message\", async (msg) => {\n  const { userId, amount } = JSON.parse(msg.body);\n  await db.account.update({ where: { userId }, data: { balance: { increment: amount } } });\n  await msg.ack();\n});\n\u002F\u002F Fix: dedup on transactionId in a single transaction.\n",[4233],{"type":37,"tag":145,"props":4234,"children":4235},{"__ignoreMap":412},[4236,4244,4351,4359,4366,4374,4441,4520,4556,4607,4622,4630,4637,4645,4704,4771,4882,4909,4924],{"type":37,"tag":418,"props":4237,"children":4238},{"class":420,"line":24},[4239],{"type":37,"tag":418,"props":4240,"children":4241},{"style":717},[4242],{"type":43,"value":4243},"\u002F\u002F Dangerous: retry wrapping a non-idempotent call\n",{"type":37,"tag":418,"props":4245,"children":4246},{"class":420,"line":508},[4247,4251,4256,4260,4264,4268,4272,4276,4280,4284,4288,4292,4296,4300,4304,4309,4313,4317,4321,4325,4330,4334,4339,4343,4347],{"type":37,"tag":418,"props":4248,"children":4249},{"style":573},[4250],{"type":43,"value":3647},{"type":37,"tag":418,"props":4252,"children":4253},{"style":436},[4254],{"type":43,"value":4255}," retry",{"type":37,"tag":418,"props":4257,"children":4258},{"style":424},[4259],{"type":43,"value":444},{"type":37,"tag":418,"props":4261,"children":4262},{"style":430},[4263],{"type":43,"value":3244},{"type":37,"tag":418,"props":4265,"children":4266},{"style":467},[4267],{"type":43,"value":500},{"type":37,"tag":418,"props":4269,"children":4270},{"style":424},[4271],{"type":43,"value":1361},{"type":37,"tag":418,"props":4273,"children":4274},{"style":430},[4275],{"type":43,"value":433},{"type":37,"tag":418,"props":4277,"children":4278},{"style":424},[4279],{"type":43,"value":1370},{"type":37,"tag":418,"props":4281,"children":4282},{"style":430},[4283],{"type":43,"value":433},{"type":37,"tag":418,"props":4285,"children":4286},{"style":436},[4287],{"type":43,"value":1062},{"type":37,"tag":418,"props":4289,"children":4290},{"style":424},[4291],{"type":43,"value":444},{"type":37,"tag":418,"props":4293,"children":4294},{"style":430},[4295],{"type":43,"value":654},{"type":37,"tag":418,"props":4297,"children":4298},{"style":424},[4299],{"type":43,"value":1430},{"type":37,"tag":418,"props":4301,"children":4302},{"style":430},[4303],{"type":43,"value":464},{"type":37,"tag":418,"props":4305,"children":4306},{"style":424},[4307],{"type":43,"value":4308}," customer ",{"type":37,"tag":418,"props":4310,"children":4311},{"style":430},[4312],{"type":43,"value":1784},{"type":37,"tag":418,"props":4314,"children":4315},{"style":424},[4316],{"type":43,"value":495},{"type":37,"tag":418,"props":4318,"children":4319},{"style":430},[4320],{"type":43,"value":464},{"type":37,"tag":418,"props":4322,"children":4323},{"style":430},[4324],{"type":43,"value":787},{"type":37,"tag":418,"props":4326,"children":4327},{"style":541},[4328],{"type":43,"value":4329}," retries",{"type":37,"tag":418,"props":4331,"children":4332},{"style":430},[4333],{"type":43,"value":664},{"type":37,"tag":418,"props":4335,"children":4336},{"style":629},[4337],{"type":43,"value":4338}," 3",{"type":37,"tag":418,"props":4340,"children":4341},{"style":430},[4342],{"type":43,"value":683},{"type":37,"tag":418,"props":4344,"children":4345},{"style":424},[4346],{"type":43,"value":495},{"type":37,"tag":418,"props":4348,"children":4349},{"style":430},[4350],{"type":43,"value":567},{"type":37,"tag":418,"props":4352,"children":4353},{"class":420,"line":20},[4354],{"type":37,"tag":418,"props":4355,"children":4356},{"style":717},[4357],{"type":43,"value":4358},"\u002F\u002F First call succeeds, response lost, retry creates a SECOND charge. Fix: pass idempotencyKey to Stripe.\n",{"type":37,"tag":418,"props":4360,"children":4361},{"class":420,"line":603},[4362],{"type":37,"tag":418,"props":4363,"children":4364},{"emptyLinePlaceholder":707},[4365],{"type":43,"value":710},{"type":37,"tag":418,"props":4367,"children":4368},{"class":420,"line":694},[4369],{"type":37,"tag":418,"props":4370,"children":4371},{"style":717},[4372],{"type":43,"value":4373},"\u002F\u002F Dangerous: POST handler with no dedup -- double-click = two orders, two charges\n",{"type":37,"tag":418,"props":4375,"children":4376},{"class":420,"line":703},[4377,4381,4385,4389,4393,4397,4401,4405,4409,4413,4417,4421,4425,4429,4433,4437],{"type":37,"tag":418,"props":4378,"children":4379},{"style":424},[4380],{"type":43,"value":427},{"type":37,"tag":418,"props":4382,"children":4383},{"style":430},[4384],{"type":43,"value":433},{"type":37,"tag":418,"props":4386,"children":4387},{"style":436},[4388],{"type":43,"value":439},{"type":37,"tag":418,"props":4390,"children":4391},{"style":424},[4392],{"type":43,"value":444},{"type":37,"tag":418,"props":4394,"children":4395},{"style":430},[4396],{"type":43,"value":449},{"type":37,"tag":418,"props":4398,"children":4399},{"style":452},[4400],{"type":43,"value":455},{"type":37,"tag":418,"props":4402,"children":4403},{"style":430},[4404],{"type":43,"value":449},{"type":37,"tag":418,"props":4406,"children":4407},{"style":430},[4408],{"type":43,"value":464},{"type":37,"tag":418,"props":4410,"children":4411},{"style":467},[4412],{"type":43,"value":470},{"type":37,"tag":418,"props":4414,"children":4415},{"style":430},[4416],{"type":43,"value":475},{"type":37,"tag":418,"props":4418,"children":4419},{"style":478},[4420],{"type":43,"value":481},{"type":37,"tag":418,"props":4422,"children":4423},{"style":430},[4424],{"type":43,"value":464},{"type":37,"tag":418,"props":4426,"children":4427},{"style":478},[4428],{"type":43,"value":490},{"type":37,"tag":418,"props":4430,"children":4431},{"style":430},[4432],{"type":43,"value":495},{"type":37,"tag":418,"props":4434,"children":4435},{"style":467},[4436],{"type":43,"value":500},{"type":37,"tag":418,"props":4438,"children":4439},{"style":430},[4440],{"type":43,"value":505},{"type":37,"tag":418,"props":4442,"children":4443},{"class":420,"line":713},[4444,4448,4452,4456,4460,4464,4468,4472,4476,4480,4484,4488,4492,4496,4500,4504,4508,4512,4516],{"type":37,"tag":418,"props":4445,"children":4446},{"style":467},[4447],{"type":43,"value":514},{"type":37,"tag":418,"props":4449,"children":4450},{"style":424},[4451],{"type":43,"value":980},{"type":37,"tag":418,"props":4453,"children":4454},{"style":430},[4455],{"type":43,"value":524},{"type":37,"tag":418,"props":4457,"children":4458},{"style":573},[4459],{"type":43,"value":742},{"type":37,"tag":418,"props":4461,"children":4462},{"style":424},[4463],{"type":43,"value":747},{"type":37,"tag":418,"props":4465,"children":4466},{"style":430},[4467],{"type":43,"value":433},{"type":37,"tag":418,"props":4469,"children":4470},{"style":424},[4471],{"type":43,"value":1158},{"type":37,"tag":418,"props":4473,"children":4474},{"style":430},[4475],{"type":43,"value":433},{"type":37,"tag":418,"props":4477,"children":4478},{"style":436},[4479],{"type":43,"value":1062},{"type":37,"tag":418,"props":4481,"children":4482},{"style":541},[4483],{"type":43,"value":444},{"type":37,"tag":418,"props":4485,"children":4486},{"style":430},[4487],{"type":43,"value":654},{"type":37,"tag":418,"props":4489,"children":4490},{"style":541},[4491],{"type":43,"value":1075},{"type":37,"tag":418,"props":4493,"children":4494},{"style":430},[4495],{"type":43,"value":664},{"type":37,"tag":418,"props":4497,"children":4498},{"style":424},[4499],{"type":43,"value":529},{"type":37,"tag":418,"props":4501,"children":4502},{"style":430},[4503],{"type":43,"value":433},{"type":37,"tag":418,"props":4505,"children":4506},{"style":424},[4507],{"type":43,"value":1248},{"type":37,"tag":418,"props":4509,"children":4510},{"style":430},[4511],{"type":43,"value":683},{"type":37,"tag":418,"props":4513,"children":4514},{"style":541},[4515],{"type":43,"value":495},{"type":37,"tag":418,"props":4517,"children":4518},{"style":430},[4519],{"type":43,"value":567},{"type":37,"tag":418,"props":4521,"children":4522},{"class":420,"line":723},[4523,4527,4532,4536,4540,4544,4548,4552],{"type":37,"tag":418,"props":4524,"children":4525},{"style":573},[4526],{"type":43,"value":1356},{"type":37,"tag":418,"props":4528,"children":4529},{"style":436},[4530],{"type":43,"value":4531}," chargeCustomer",{"type":37,"tag":418,"props":4533,"children":4534},{"style":541},[4535],{"type":43,"value":444},{"type":37,"tag":418,"props":4537,"children":4538},{"style":424},[4539],{"type":43,"value":1158},{"type":37,"tag":418,"props":4541,"children":4542},{"style":430},[4543],{"type":43,"value":433},{"type":37,"tag":418,"props":4545,"children":4546},{"style":424},[4547],{"type":43,"value":1291},{"type":37,"tag":418,"props":4549,"children":4550},{"style":541},[4551],{"type":43,"value":495},{"type":37,"tag":418,"props":4553,"children":4554},{"style":430},[4555],{"type":43,"value":567},{"type":37,"tag":418,"props":4557,"children":4558},{"class":420,"line":819},[4559,4563,4567,4571,4575,4579,4583,4587,4591,4595,4599,4603],{"type":37,"tag":418,"props":4560,"children":4561},{"style":424},[4562],{"type":43,"value":1730},{"type":37,"tag":418,"props":4564,"children":4565},{"style":430},[4566],{"type":43,"value":433},{"type":37,"tag":418,"props":4568,"children":4569},{"style":436},[4570],{"type":43,"value":622},{"type":37,"tag":418,"props":4572,"children":4573},{"style":541},[4574],{"type":43,"value":444},{"type":37,"tag":418,"props":4576,"children":4577},{"style":629},[4578],{"type":43,"value":1747},{"type":37,"tag":418,"props":4580,"children":4581},{"style":541},[4582],{"type":43,"value":495},{"type":37,"tag":418,"props":4584,"children":4585},{"style":430},[4586],{"type":43,"value":433},{"type":37,"tag":418,"props":4588,"children":4589},{"style":436},[4590],{"type":43,"value":645},{"type":37,"tag":418,"props":4592,"children":4593},{"style":541},[4594],{"type":43,"value":444},{"type":37,"tag":418,"props":4596,"children":4597},{"style":424},[4598],{"type":43,"value":1158},{"type":37,"tag":418,"props":4600,"children":4601},{"style":541},[4602],{"type":43,"value":495},{"type":37,"tag":418,"props":4604,"children":4605},{"style":430},[4606],{"type":43,"value":567},{"type":37,"tag":418,"props":4608,"children":4609},{"class":420,"line":871},[4610,4614,4618],{"type":37,"tag":418,"props":4611,"children":4612},{"style":430},[4613],{"type":43,"value":1784},{"type":37,"tag":418,"props":4615,"children":4616},{"style":424},[4617],{"type":43,"value":495},{"type":37,"tag":418,"props":4619,"children":4620},{"style":430},[4621],{"type":43,"value":567},{"type":37,"tag":418,"props":4623,"children":4624},{"class":420,"line":945},[4625],{"type":37,"tag":418,"props":4626,"children":4627},{"style":717},[4628],{"type":43,"value":4629},"\u002F\u002F Fix: require and check Idempotency-Key header.\n",{"type":37,"tag":418,"props":4631,"children":4632},{"class":420,"line":953},[4633],{"type":37,"tag":418,"props":4634,"children":4635},{"emptyLinePlaceholder":707},[4636],{"type":43,"value":710},{"type":37,"tag":418,"props":4638,"children":4639},{"class":420,"line":961},[4640],{"type":37,"tag":418,"props":4641,"children":4642},{"style":717},[4643],{"type":43,"value":4644},"\u002F\u002F Dangerous: queue consumer with INCREMENT -- SQS delivers twice = balance incremented twice\n",{"type":37,"tag":418,"props":4646,"children":4647},{"class":420,"line":970},[4648,4652,4656,4660,4664,4668,4672,4676,4680,4684,4688,4692,4696,4700],{"type":37,"tag":418,"props":4649,"children":4650},{"style":424},[4651],{"type":43,"value":2723},{"type":37,"tag":418,"props":4653,"children":4654},{"style":430},[4655],{"type":43,"value":433},{"type":37,"tag":418,"props":4657,"children":4658},{"style":436},[4659],{"type":43,"value":2732},{"type":37,"tag":418,"props":4661,"children":4662},{"style":424},[4663],{"type":43,"value":444},{"type":37,"tag":418,"props":4665,"children":4666},{"style":430},[4667],{"type":43,"value":449},{"type":37,"tag":418,"props":4669,"children":4670},{"style":452},[4671],{"type":43,"value":2745},{"type":37,"tag":418,"props":4673,"children":4674},{"style":430},[4675],{"type":43,"value":449},{"type":37,"tag":418,"props":4677,"children":4678},{"style":430},[4679],{"type":43,"value":464},{"type":37,"tag":418,"props":4681,"children":4682},{"style":467},[4683],{"type":43,"value":470},{"type":37,"tag":418,"props":4685,"children":4686},{"style":430},[4687],{"type":43,"value":475},{"type":37,"tag":418,"props":4689,"children":4690},{"style":478},[4691],{"type":43,"value":2766},{"type":37,"tag":418,"props":4693,"children":4694},{"style":430},[4695],{"type":43,"value":495},{"type":37,"tag":418,"props":4697,"children":4698},{"style":467},[4699],{"type":43,"value":500},{"type":37,"tag":418,"props":4701,"children":4702},{"style":430},[4703],{"type":43,"value":505},{"type":37,"tag":418,"props":4705,"children":4706},{"class":420,"line":1034},[4707,4711,4715,4719,4723,4727,4731,4735,4739,4743,4747,4751,4755,4759,4763,4767],{"type":37,"tag":418,"props":4708,"children":4709},{"style":467},[4710],{"type":43,"value":514},{"type":37,"tag":418,"props":4712,"children":4713},{"style":430},[4714],{"type":43,"value":787},{"type":37,"tag":418,"props":4716,"children":4717},{"style":424},[4718],{"type":43,"value":1196},{"type":37,"tag":418,"props":4720,"children":4721},{"style":430},[4722],{"type":43,"value":464},{"type":37,"tag":418,"props":4724,"children":4725},{"style":424},[4726],{"type":43,"value":1430},{"type":37,"tag":418,"props":4728,"children":4729},{"style":430},[4730],{"type":43,"value":683},{"type":37,"tag":418,"props":4732,"children":4733},{"style":430},[4734],{"type":43,"value":524},{"type":37,"tag":418,"props":4736,"children":4737},{"style":424},[4738],{"type":43,"value":2823},{"type":37,"tag":418,"props":4740,"children":4741},{"style":430},[4742],{"type":43,"value":433},{"type":37,"tag":418,"props":4744,"children":4745},{"style":436},[4746],{"type":43,"value":2832},{"type":37,"tag":418,"props":4748,"children":4749},{"style":541},[4750],{"type":43,"value":444},{"type":37,"tag":418,"props":4752,"children":4753},{"style":424},[4754],{"type":43,"value":2766},{"type":37,"tag":418,"props":4756,"children":4757},{"style":430},[4758],{"type":43,"value":433},{"type":37,"tag":418,"props":4760,"children":4761},{"style":424},[4762],{"type":43,"value":1248},{"type":37,"tag":418,"props":4764,"children":4765},{"style":541},[4766],{"type":43,"value":495},{"type":37,"tag":418,"props":4768,"children":4769},{"style":430},[4770],{"type":43,"value":567},{"type":37,"tag":418,"props":4772,"children":4773},{"class":420,"line":1140},[4774,4778,4782,4786,4790,4794,4798,4802,4806,4810,4814,4818,4822,4826,4830,4834,4838,4842,4846,4850,4854,4858,4862,4866,4870,4874,4878],{"type":37,"tag":418,"props":4775,"children":4776},{"style":573},[4777],{"type":43,"value":1356},{"type":37,"tag":418,"props":4779,"children":4780},{"style":424},[4781],{"type":43,"value":747},{"type":37,"tag":418,"props":4783,"children":4784},{"style":430},[4785],{"type":43,"value":433},{"type":37,"tag":418,"props":4787,"children":4788},{"style":424},[4789],{"type":43,"value":3050},{"type":37,"tag":418,"props":4791,"children":4792},{"style":430},[4793],{"type":43,"value":433},{"type":37,"tag":418,"props":4795,"children":4796},{"style":436},[4797],{"type":43,"value":1580},{"type":37,"tag":418,"props":4799,"children":4800},{"style":541},[4801],{"type":43,"value":444},{"type":37,"tag":418,"props":4803,"children":4804},{"style":430},[4805],{"type":43,"value":654},{"type":37,"tag":418,"props":4807,"children":4808},{"style":541},[4809],{"type":43,"value":778},{"type":37,"tag":418,"props":4811,"children":4812},{"style":430},[4813],{"type":43,"value":664},{"type":37,"tag":418,"props":4815,"children":4816},{"style":430},[4817],{"type":43,"value":787},{"type":37,"tag":418,"props":4819,"children":4820},{"style":424},[4821],{"type":43,"value":1196},{"type":37,"tag":418,"props":4823,"children":4824},{"style":430},[4825],{"type":43,"value":3087},{"type":37,"tag":418,"props":4827,"children":4828},{"style":541},[4829],{"type":43,"value":1075},{"type":37,"tag":418,"props":4831,"children":4832},{"style":430},[4833],{"type":43,"value":664},{"type":37,"tag":418,"props":4835,"children":4836},{"style":430},[4837],{"type":43,"value":787},{"type":37,"tag":418,"props":4839,"children":4840},{"style":541},[4841],{"type":43,"value":3104},{"type":37,"tag":418,"props":4843,"children":4844},{"style":430},[4845],{"type":43,"value":664},{"type":37,"tag":418,"props":4847,"children":4848},{"style":430},[4849],{"type":43,"value":787},{"type":37,"tag":418,"props":4851,"children":4852},{"style":541},[4853],{"type":43,"value":3117},{"type":37,"tag":418,"props":4855,"children":4856},{"style":430},[4857],{"type":43,"value":664},{"type":37,"tag":418,"props":4859,"children":4860},{"style":424},[4861],{"type":43,"value":1430},{"type":37,"tag":418,"props":4863,"children":4864},{"style":430},[4865],{"type":43,"value":683},{"type":37,"tag":418,"props":4867,"children":4868},{"style":430},[4869],{"type":43,"value":683},{"type":37,"tag":418,"props":4871,"children":4872},{"style":430},[4873],{"type":43,"value":683},{"type":37,"tag":418,"props":4875,"children":4876},{"style":541},[4877],{"type":43,"value":495},{"type":37,"tag":418,"props":4879,"children":4880},{"style":430},[4881],{"type":43,"value":567},{"type":37,"tag":418,"props":4883,"children":4884},{"class":420,"line":1177},[4885,4889,4893,4897,4901,4905],{"type":37,"tag":418,"props":4886,"children":4887},{"style":573},[4888],{"type":43,"value":1356},{"type":37,"tag":418,"props":4890,"children":4891},{"style":424},[4892],{"type":43,"value":3230},{"type":37,"tag":418,"props":4894,"children":4895},{"style":430},[4896],{"type":43,"value":433},{"type":37,"tag":418,"props":4898,"children":4899},{"style":436},[4900],{"type":43,"value":3239},{"type":37,"tag":418,"props":4902,"children":4903},{"style":541},[4904],{"type":43,"value":3244},{"type":37,"tag":418,"props":4906,"children":4907},{"style":430},[4908],{"type":43,"value":567},{"type":37,"tag":418,"props":4910,"children":4911},{"class":420,"line":1299},[4912,4916,4920],{"type":37,"tag":418,"props":4913,"children":4914},{"style":430},[4915],{"type":43,"value":1784},{"type":37,"tag":418,"props":4917,"children":4918},{"style":424},[4919],{"type":43,"value":495},{"type":37,"tag":418,"props":4921,"children":4922},{"style":430},[4923],{"type":43,"value":567},{"type":37,"tag":418,"props":4925,"children":4926},{"class":420,"line":1316},[4927],{"type":37,"tag":418,"props":4928,"children":4929},{"style":717},[4930],{"type":43,"value":4931},"\u002F\u002F Fix: dedup on transactionId in a single transaction.\n",{"type":37,"tag":58,"props":4933,"children":4935},{"id":4934},"related-traps",[4936],{"type":43,"value":4937},"Related Traps",{"type":37,"tag":4939,"props":4940,"children":4941},"ul",{},[4942,4952,4962],{"type":37,"tag":74,"props":4943,"children":4944},{},[4945,4950],{"type":37,"tag":52,"props":4946,"children":4947},{},[4948],{"type":43,"value":4949},"Race Conditions",{"type":43,"value":4951}," -- idempotency checks are themselves vulnerable to races. Two retries arriving simultaneously can both pass the \"already processed?\" check. The dedup record must be created atomically with the business operation (same transaction, unique constraint).",{"type":37,"tag":74,"props":4953,"children":4954},{},[4955,4960],{"type":37,"tag":52,"props":4956,"children":4957},{},[4958],{"type":43,"value":4959},"Consistency Models",{"type":43,"value":4961}," -- if your dedup check reads from a replica but the dedup record was written to the primary, replica lag can cause the check to miss the duplicate. Dedup checks must read from the primary.",{"type":37,"tag":74,"props":4963,"children":4964},{},[4965,4970],{"type":37,"tag":52,"props":4966,"children":4967},{},[4968],{"type":43,"value":4969},"Retry Storms",{"type":43,"value":4971}," -- retrying non-idempotent operations doesn't just create duplicates -- it amplifies load. Idempotency + retry storms = data corruption at scale.",{"type":37,"tag":4973,"props":4974,"children":4975},"style",{},[4976],{"type":43,"value":4977},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":4979,"total":1537},[4980,4999,5012,5022,5039,5053,5067,5084,5097,5109,5120,5131],{"slug":4981,"name":4981,"fn":4982,"description":4983,"org":4984,"tags":4985,"stars":4996,"repoUrl":4997,"updatedAt":4998},"trigger-authoring-chat-agent","author durable AI chat agents with Trigger.dev","Author and run a durable AI chat agent with chat.agent from @trigger.dev\u002Fsdk\u002Fai: the per-turn run loop, why you MUST spread ...chat.toStreamTextOptions() first, returning a StreamTextResult vs calling chat.pipe(), the two server actions (chat.createStartSessionAction + auth.createPublicToken), and wiring useChat to useTriggerChatTransport. Load this when building, modifying, or debugging a chat backend (the agent task or its lifecycle hooks) or its React transport, when declaring typed tools or custom data parts, or when migrating a plain AI SDK streamText route to chat.agent.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[4986,4989,4992,4993],{"name":4987,"slug":4988,"type":16},"Agents","agents",{"name":4990,"slug":4991,"type":16},"SDK","sdk",{"name":9,"slug":8,"type":16},{"name":4994,"slug":4995,"type":16},"Workflow Automation","workflow-automation",14401,"https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Ftrigger.dev","2026-07-02T17:12:52.307135",{"slug":5000,"name":5000,"fn":5001,"description":5002,"org":5003,"tags":5004,"stars":4996,"repoUrl":4997,"updatedAt":5011},"trigger-authoring-tasks","author backend Trigger.dev tasks","Covers writing backend Trigger.dev tasks with @trigger.dev\u002Fsdk: defining task() and schemaTask(), the run function and its ctx, retries, waits, queues and concurrency, idempotency keys, run metadata, logging, triggering other tasks (and the Result shape), scheduled\u002Fcron tasks, and the essentials of trigger.config.ts. Load this whenever you are authoring or editing code inside a \u002Ftrigger directory, defining a task, or writing backend code that triggers tasks. Realtime\u002FReact hooks and AI chat are covered by separate skills.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5005,5008,5009,5010],{"name":5006,"slug":5007,"type":16},"Backend","backend",{"name":4990,"slug":4991,"type":16},{"name":9,"slug":8,"type":16},{"name":4994,"slug":4995,"type":16},"2026-07-02T17:12:48.396964",{"slug":5013,"name":5013,"fn":5014,"description":5015,"org":5016,"tags":5017,"stars":4996,"repoUrl":4997,"updatedAt":5021},"trigger-chat-agent-advanced","manage Trigger.dev chat sessions and transports","Advanced and operational chat.agent capabilities for Trigger.dev, loaded on demand. Load this when working on the raw Sessions primitive (sessions \u002F SessionHandle), a custom chat transport or the realtime wire protocol, durable sub-agents (AgentChat, chat.stream.writer), human-in-the-loop, steering, actions, background injection (chat.defer \u002F chat.inject), fast starts (preload, Head Start via @trigger.dev\u002Fsdk\u002Fchat-server), context resilience (compaction, recovery boot, OOM, large payloads), chat.local run-scoped state, offline testing with mockChatAgent, or prerelease\u002Fversion upgrades. For the everyday chat.agent({...}) definition and the useTriggerChatTransport happy path, use the trigger-authoring-chat-agent skill instead.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5018,5019,5020],{"name":4987,"slug":4988,"type":16},{"name":9,"slug":8,"type":16},{"name":4994,"slug":4995,"type":16},"2026-07-02T17:12:51.03018",{"slug":5023,"name":5023,"fn":5024,"description":5025,"org":5026,"tags":5027,"stars":4996,"repoUrl":4997,"updatedAt":5038},"trigger-realtime-and-frontend","subscribe to Trigger.dev runs in realtime","Trigger.dev client\u002Ffrontend surface: subscribe to runs in realtime (runs.subscribeToRun and the @trigger.dev\u002Freact-hooks hook useRealtimeRun), consume metadata and AI\u002Ftext streams in React (useRealtimeStream), trigger tasks from the browser (useTaskTrigger, useRealtimeTaskTrigger), and mint scoped frontend credentials with auth.createPublicToken \u002F auth.createTriggerPublicToken. Load when wiring a frontend (React\u002FNext.js\u002FRemix) or backend-for-frontend to show live run progress, status badges, token streams, trigger buttons, or wait-token approval UIs. NOT for writing the backend task itself (streams.define \u002F metadata.set is trigger-authoring-tasks territory); this is the consumer side.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5028,5031,5034,5037],{"name":5029,"slug":5030,"type":16},"Frontend","frontend",{"name":5032,"slug":5033,"type":16},"React","react",{"name":5035,"slug":5036,"type":16},"Real-time","real-time",{"name":9,"slug":8,"type":16},"2026-07-02T17:12:49.717706",{"slug":5040,"name":5040,"fn":5041,"description":5042,"org":5043,"tags":5044,"stars":1624,"repoUrl":5051,"updatedAt":5052},"trigger-agents","orchestrate AI agents with Trigger.dev","AI agent patterns with Trigger.dev - orchestration, parallelization, routing, evaluator-optimizer, and human-in-the-loop. Use when building LLM-powered tasks that need parallel workers, approval gates, tool calling, or multi-step agent workflows.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5045,5046,5049,5050],{"name":4987,"slug":4988,"type":16},{"name":5047,"slug":5048,"type":16},"Multi-Agent","multi-agent",{"name":9,"slug":8,"type":16},{"name":4994,"slug":4995,"type":16},"https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Fskills","2026-04-06T18:54:46.023553",{"slug":5054,"name":5054,"fn":5055,"description":5056,"org":5057,"tags":5058,"stars":1624,"repoUrl":5051,"updatedAt":5066},"trigger-config","configure Trigger.dev project settings","Configure Trigger.dev projects with trigger.config.ts. Use when setting up build extensions for Prisma, Playwright, FFmpeg, Python, or customizing deployment settings.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5059,5062,5065],{"name":5060,"slug":5061,"type":16},"Configuration","configuration",{"name":5063,"slug":5064,"type":16},"Deployment","deployment",{"name":9,"slug":8,"type":16},"2026-04-06T18:54:44.764258",{"slug":5068,"name":5068,"fn":5069,"description":5070,"org":5071,"tags":5072,"stars":1624,"repoUrl":5051,"updatedAt":5083},"trigger-cost-savings","optimize Trigger.dev task costs","Analyze Trigger.dev tasks, schedules, and runs for cost optimization opportunities. Use when asked to reduce spend, optimize costs, audit usage, right-size machines, or review task efficiency. Requires Trigger.dev MCP tools for run analysis.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5073,5076,5079,5082],{"name":5074,"slug":5075,"type":16},"Analytics","analytics",{"name":5077,"slug":5078,"type":16},"Cost Optimization","cost-optimization",{"name":5080,"slug":5081,"type":16},"Operations","operations",{"name":9,"slug":8,"type":16},"2026-04-06T18:54:48.555552",{"slug":5085,"name":5085,"fn":5086,"description":5087,"org":5088,"tags":5089,"stars":1624,"repoUrl":5051,"updatedAt":5096},"trigger-realtime","monitor Trigger.dev tasks in real-time","Subscribe to Trigger.dev task runs in real-time from frontend and backend. Use when building progress indicators, live dashboards, streaming AI\u002FLLM responses, or React components that display task status.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5090,5091,5094,5095],{"name":5029,"slug":5030,"type":16},{"name":5092,"slug":5093,"type":16},"Observability","observability",{"name":5035,"slug":5036,"type":16},{"name":9,"slug":8,"type":16},"2026-04-06T18:54:47.293822",{"slug":5098,"name":5098,"fn":5099,"description":5100,"org":5101,"tags":5102,"stars":1624,"repoUrl":5051,"updatedAt":5108},"trigger-setup","set up Trigger.dev in projects","Set up Trigger.dev in your project. Use when adding Trigger.dev for the first time, creating trigger.config.ts, or initializing the trigger directory.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5103,5104,5107],{"name":5060,"slug":5061,"type":16},{"name":5105,"slug":5106,"type":16},"Local Development","local-development",{"name":9,"slug":8,"type":16},"2026-04-06T18:54:42.280816",{"slug":5110,"name":5110,"fn":5111,"description":5112,"org":5113,"tags":5114,"stars":1624,"repoUrl":5051,"updatedAt":5119},"trigger-tasks","build durable background tasks with Trigger.dev","Build AI agents, workflows and durable background tasks with Trigger.dev. Use when creating tasks, triggering jobs, handling retries, scheduling cron jobs, or implementing queues and concurrency control.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5115,5116,5117,5118],{"name":4987,"slug":4988,"type":16},{"name":5006,"slug":5007,"type":16},{"name":9,"slug":8,"type":16},{"name":4994,"slug":4995,"type":16},"2026-04-06T18:54:43.514369",{"slug":5121,"name":5121,"fn":5122,"description":5123,"org":5124,"tags":5125,"stars":20,"repoUrl":21,"updatedAt":5130},"staff-engineering-skills-backpressure","implement backpressure in streaming pipelines","Prevent unbounded resource growth when producers outpace consumers. Use when writing producer-consumer code, queue processing, batch operations, fan-out patterns, streaming pipelines, or any code where work is generated faster than it can be processed. Activates on patterns like Promise.all on dynamic-sized arrays, unbounded in-memory queues, producer loops without depth checks, fire-and-forget async calls in loops, or any buffer between a producer and consumer without a size limit.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5126,5127],{"name":14,"slug":15,"type":16},{"name":5128,"slug":5129,"type":16},"Performance","performance","2026-06-17T08:40:42.723559",{"slug":5132,"name":5132,"fn":5133,"description":5134,"org":5135,"tags":5136,"stars":20,"repoUrl":21,"updatedAt":5145},"staff-engineering-skills-cache-invalidation","implement cache invalidation strategies","Prevent stale data bugs caused by missing or incomplete cache invalidation. Use when adding caching layers (Redis, in-memory Map, CDN, HTTP cache headers), optimizing read performance, or reviewing code that caches query results, API responses, or computed values. Activates on patterns like cache.set without cache.delete on write paths, unbounded Map\u002Fobject caches, TTL-only invalidation on security-sensitive data, Cache-Control headers on mutable content, or any caching where the write path doesn't invalidate the read cache.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5137,5138,5141,5144],{"name":14,"slug":15,"type":16},{"name":5139,"slug":5140,"type":16},"Caching","caching",{"name":5142,"slug":5143,"type":16},"Engineering","engineering",{"name":5128,"slug":5129,"type":16},"2026-06-17T08:40:45.194583",{"items":5147,"total":1140},[5148,5153,5160,5170,5182,5195,5207],{"slug":5121,"name":5121,"fn":5122,"description":5123,"org":5149,"tags":5150,"stars":20,"repoUrl":21,"updatedAt":5130},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5151,5152],{"name":14,"slug":15,"type":16},{"name":5128,"slug":5129,"type":16},{"slug":5132,"name":5132,"fn":5133,"description":5134,"org":5154,"tags":5155,"stars":20,"repoUrl":21,"updatedAt":5145},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5156,5157,5158,5159],{"name":14,"slug":15,"type":16},{"name":5139,"slug":5140,"type":16},{"name":5142,"slug":5143,"type":16},{"name":5128,"slug":5129,"type":16},{"slug":5161,"name":5161,"fn":5162,"description":5163,"org":5164,"tags":5165,"stars":20,"repoUrl":21,"updatedAt":5169},"staff-engineering-skills-cardinality","prevent cardinality traps in systems code","Detect and prevent cardinality traps in systems code. Use when writing code that iterates over collections, stores items in memory, creates per-entity resources, or fans out operations across a set of items. Activates on patterns like loops over query results, in-memory Maps\u002FSets populated from databases, or \"one X per Y\" resource allocation.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5166,5167,5168],{"name":14,"slug":15,"type":16},{"name":5142,"slug":5143,"type":16},{"name":5128,"slug":5129,"type":16},"2026-06-17T08:40:40.264608",{"slug":5171,"name":5171,"fn":5172,"description":5173,"org":5174,"tags":5175,"stars":20,"repoUrl":21,"updatedAt":5181},"staff-engineering-skills-clock-skew","prevent clock skew bugs in distributed systems","Prevent bugs caused by assuming clocks are synchronized or monotonic. Use when writing code that compares timestamps across machines, measures durations, sets lock expiry, orders distributed events, deduplicates by time window, or uses Date.now() for anything other than logging or display. Activates on patterns like Date.now() used for duration measurement, absolute timestamp expiry shared across machines, wall clock timestamps for event ordering, last-write-wins conflict resolution with timestamps, or timeout calculations using wall clock time.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5176,5177,5180],{"name":14,"slug":15,"type":16},{"name":5178,"slug":5179,"type":16},"Debugging","debugging",{"name":5142,"slug":5143,"type":16},"2026-06-17T08:40:37.803541",{"slug":5183,"name":5183,"fn":5184,"description":5185,"org":5186,"tags":5187,"stars":20,"repoUrl":21,"updatedAt":5194},"staff-engineering-skills-consistency-models","manage consistency models in distributed systems","Prevent stale read bugs caused by replica lag, cache staleness, and index delay. Use when writing code that reads data after writing it, uses read replicas, caches query results, reads from search indexes, or builds event-driven read models. Activates on patterns like create-then-redirect, update-then-read, cache-aside with TTL, search-after-create, or any write followed by a read that might hit a different data source.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5188,5189,5192,5193],{"name":14,"slug":15,"type":16},{"name":5190,"slug":5191,"type":16},"Database","database",{"name":5142,"slug":5143,"type":16},{"name":5128,"slug":5129,"type":16},"2026-06-17T08:40:46.442182",{"slug":5196,"name":5196,"fn":5197,"description":5198,"org":5199,"tags":5200,"stars":20,"repoUrl":21,"updatedAt":5206},"staff-engineering-skills-denormalization","prevent data model denormalization traps","Detect and prevent denormalization traps when designing data models. Use when writing code that copies fields between tables, embeds related data in documents, caches composed objects, or adds redundant columns to avoid joins. Activates on patterns like storing derived\u002Fcopied data, syncing fields across tables, or embedding nested objects in document stores.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5201,5202,5205],{"name":14,"slug":15,"type":16},{"name":5203,"slug":5204,"type":16},"Data Modeling","data-modeling",{"name":5190,"slug":5191,"type":16},"2026-06-17T08:40:53.835868",{"slug":5208,"name":5208,"fn":5209,"description":5210,"org":5211,"tags":5212,"stars":20,"repoUrl":21,"updatedAt":5216},"staff-engineering-skills-distributed-system-fallacies","design resilient distributed systems","Prevent failures caused by treating network calls like function calls. Use when writing code that calls external services, splits a monolith into microservices, chains multiple API calls, orchestrates distributed workflows, or handles requests that depend on other services. Activates on patterns like sequential service calls without timeouts, fetch\u002Faxios calls without error handling, multi-service writes without compensation, hardcoded service URLs, or any code that assumes the network is reliable, fast, or free.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5213,5214,5215],{"name":18,"slug":19,"type":16},{"name":14,"slug":15,"type":16},{"name":5142,"slug":5143,"type":16},"2026-06-17T08:40:47.666795"]