[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-trigger-dev-staff-engineering-skills-streams-vs-batch":3,"mdc--uvgv4k-key":34,"related-org-trigger-dev-staff-engineering-skills-streams-vs-batch":2932,"related-repo-trigger-dev-staff-engineering-skills-streams-vs-batch":3101},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":12,"stars":23,"repoUrl":24,"updatedAt":25,"license":26,"forks":27,"topics":28,"repo":29,"sourceUrl":32,"mdContent":33},"staff-engineering-skills-streams-vs-batch","choose data processing models","Choose the right processing model before writing code. Use when building data pipelines, processing queues, handling webhooks, sending notifications, aggregating metrics, or any system that processes a collection of items over time. Activates on patterns like cron jobs processing \"new\" items, polling for unprocessed rows, setInterval-based processing, or collecting items into arrays before processing.",{"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,20],{"name":14,"slug":15,"type":16},"Architecture","architecture","tag",{"name":18,"slug":19,"type":16},"Data Engineering","data-engineering",{"name":21,"slug":22,"type":16},"Data Pipeline","data-pipeline",3,"https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Fstaff-engineering-skills","2026-06-17T08:40:55.062477",null,1,[],{"repoUrl":24,"stars":23,"forks":27,"topics":30,"description":31},[],"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-streams-vs-batch","---\nname: staff-engineering-skills-streams-vs-batch\ndescription: Choose the right processing model before writing code. Use when building data pipelines, processing queues, handling webhooks, sending notifications, aggregating metrics, or any system that processes a collection of items over time. Activates on patterns like cron jobs processing \"new\" items, polling for unprocessed rows, setInterval-based processing, or collecting items into arrays before processing.\n---\n\n# Streams vs Batch Trap\n\nBatch-to-stream is a rewrite, not a refactor. Before writing a processing pipeline, ask: **what's the latency requirement, and will it change?**\n\n## Decision Framework\n\nAsk these questions before writing the first line of processing code:\n\n| Question | Batch | Stream |\n|----------|-------|--------|\n| Acceptable latency? | Minutes to hours | Seconds or less |\n| Throughput trajectory? | Stable or slow-growing | Growing fast or unpredictable |\n| Failure isolation? | Whole batch can retry | Must handle per-item failure |\n| Ordering matters? | No, or within batch is fine | Yes, across items |\n| \"Real-time\" ever mentioned? | No | Yes -- build for it now |\n\n**If the answer to ANY row points to stream, build for streaming from the start.** You cannot cheaply add streaming later.\n\n## The Rule\n\nReducing a batch interval is not a scaling strategy. A 10-second batch interval is a bad stream processor -- it has all the complexity of streaming with none of the benefits (no ordering, no backpressure, no offset tracking, overlap risk).\n\n## Detection: Batch Patterns That Will Need Streaming\n\n**Stop and reassess if you see:**\n\n1. **A cron job processing \"new\" or \"unprocessed\" items** -- `SELECT * FROM events WHERE processed = false`. What's the latency requirement? If \"as fast as possible,\" this is the wrong model.\n\n2. **`setInterval` or `setTimeout` for processing** -- what happens when processing takes longer than the interval? Overlapping batches cause duplicate processing and resource contention.\n\n3. **Shrinking batch intervals over time** -- started at 5 minutes, now at 10 seconds. This is the symptom. The disease is: you need streaming.\n\n4. **Items collected into an array before processing** -- what bounds the array? If it's time-based (\"all items in the last 5 minutes\"), memory grows with throughput.\n\n5. **\"We'll add real-time later\"** -- flag this immediately. This is not an incremental change. The data flow, error handling, and ordering assumptions are fundamentally different.\n\n## When Batch Is Correct\n\nBatch is the right choice when:\n- Latency requirements are hours or days (daily reports, nightly ETL, weekly digests)\n- The processing needs a complete view of a time window (aggregations, reconciliation)\n- Throughput is stable and predictable\n- The workload is compute-heavy and benefits from bulk operations (ML training, data export)\n\n```typescript\n\u002F\u002F Batch is correct here: daily revenue report. Nobody needs this in real-time.\nasync function generateDailyReport() {\n  const revenue = await db.$queryRaw`\n    SELECT DATE_TRUNC('hour', created_at) as hour, SUM(amount) as total\n    FROM orders\n    WHERE created_at >= ${startOfDay} AND created_at \u003C ${endOfDay}\n    GROUP BY DATE_TRUNC('hour', created_at)\n  `;\n  await saveReport({ date: today, hourlyRevenue: revenue });\n}\n```\n\n## When You Need Event-Driven Processing\n\nFor most applications, you don't need Kafka. You need event-driven task processing with proper failure handling.\n\n```typescript\n\u002F\u002F Process each item as it arrives. Failure isolated per item.\n\u002F\u002F Latency is seconds, not minutes. Scales by adding workers.\nimport { task } from \"@trigger.dev\u002Fsdk\";\n\nexport const processSignup = task({\n  id: \"process-signup\",\n  retry: { maxAttempts: 3 },\n  run: async (payload: { userId: string }) => {\n    const user = await db.user.findUnique({ where: { id: payload.userId } });\n    await sendWelcomeEmail(user);\n    await createDefaultWorkspace(user);\n    await trackSignupAnalytics(user);\n  },\n});\n\n\u002F\u002F In the signup handler -- trigger immediately, don't batch\nasync function handleSignup(data: SignupInput) {\n  const user = await db.user.create({ data });\n  await processSignup.trigger({ userId: user.id });\n  return user;\n}\n```\n\n## Micro-Batching: The Middle Ground\n\nWhen per-item overhead is too high but you need low latency, use small frequent batches with per-item failure handling.\n\n```typescript\nimport { task } from \"@trigger.dev\u002Fsdk\";\n\nexport const processEventBatch = task({\n  id: \"process-event-batch\",\n  queue: { concurrencyLimit: 5 },\n  run: async (payload: { eventIds: string[] }) => {\n    const events = await db.event.findMany({\n      where: { id: { in: payload.eventIds } },\n    });\n\n    \u002F\u002F Process individually within the batch -- failure isolation\n    const results = await Promise.allSettled(\n      events.map(event => processEvent(event))\n    );\n\n    \u002F\u002F Retry only failures, not the whole batch\n    const failures = results\n      .map((r, i) => r.status === \"rejected\" ? events[i] : null)\n      .filter(Boolean);\n    if (failures.length > 0) await enqueueRetry(failures);\n  },\n});\n```\n\n## Anti-Patterns\n\n```typescript\n\u002F\u002F Dangerous: polling for unprocessed rows on a timer\n\u002F\u002F Race conditions with multiple instances, no failure isolation,\n\u002F\u002F duplicate emails if process crashes between send and flag update\nconst job = cron(\"*\u002F5 * * * *\", async () => {\n  const users = await db.user.findMany({ where: { welcomeEmailSent: false } });\n  for (const user of users) {\n    await sendWelcomeEmail(user);\n    await db.user.update({ where: { id: user.id }, data: { welcomeEmailSent: true } });\n  }\n});\n\n\u002F\u002F Dangerous: shrinking interval as scaling strategy\n\u002F\u002F Started at 5min, now 10sec. What if processing takes 15sec? Overlap.\nsetInterval(async () => {\n  const events = await db.event.findMany({\n    where: { processedAt: null }, take: 1000,\n  });\n  await processEvents(events); \u002F\u002F takes longer than interval under load\n}, 10_000);\n\n\u002F\u002F Dangerous: one bad item kills the whole batch\nconst orders = await db.order.findMany({ where: { date: today } });\nconst report = orders.map(order => ({\n  revenue: calculateRevenue(order),  \u002F\u002F throws on malformed data\n  tax: calculateTax(order),          \u002F\u002F throws on missing region\n}));\n\u002F\u002F Order #5,000 throws. All 50,000 orders lost. Retry all or skip?\n```\n\n## Related Traps\n\n- **Cardinality** -- high-cardinality data growing over time is the forcing function that breaks batch. When batch size grows because data volume grows, you need streaming, not a shorter interval.\n- **Backpressure** -- stream processors handle backpressure naturally (consumer pulls at its own pace). Batch processors don't -- if the batch is bigger than the system can handle, it fails.\n- **Idempotency** -- stream\u002Fevent processing requires idempotent handlers because messages can be delivered more than once. Batch systems often skip this and break when they retry.\n- **Race Conditions** -- polling-based batch processing is inherently racy. Two instances polling for `WHERE processed = false` at the same time pick up the same rows.\n",{"data":35,"body":36},{"name":4,"description":6},{"type":37,"children":38},"root",[39,48,60,67,72,195,205,211,216,222,230,308,314,319,343,607,613,618,1292,1298,1303,2016,2022,2869,2875,2926],{"type":40,"tag":41,"props":42,"children":44},"element","h1",{"id":43},"streams-vs-batch-trap",[45],{"type":46,"value":47},"text","Streams vs Batch Trap",{"type":40,"tag":49,"props":50,"children":51},"p",{},[52,54],{"type":46,"value":53},"Batch-to-stream is a rewrite, not a refactor. Before writing a processing pipeline, ask: ",{"type":40,"tag":55,"props":56,"children":57},"strong",{},[58],{"type":46,"value":59},"what's the latency requirement, and will it change?",{"type":40,"tag":61,"props":62,"children":64},"h2",{"id":63},"decision-framework",[65],{"type":46,"value":66},"Decision Framework",{"type":40,"tag":49,"props":68,"children":69},{},[70],{"type":46,"value":71},"Ask these questions before writing the first line of processing code:",{"type":40,"tag":73,"props":74,"children":75},"table",{},[76,100],{"type":40,"tag":77,"props":78,"children":79},"thead",{},[80],{"type":40,"tag":81,"props":82,"children":83},"tr",{},[84,90,95],{"type":40,"tag":85,"props":86,"children":87},"th",{},[88],{"type":46,"value":89},"Question",{"type":40,"tag":85,"props":91,"children":92},{},[93],{"type":46,"value":94},"Batch",{"type":40,"tag":85,"props":96,"children":97},{},[98],{"type":46,"value":99},"Stream",{"type":40,"tag":101,"props":102,"children":103},"tbody",{},[104,123,141,159,177],{"type":40,"tag":81,"props":105,"children":106},{},[107,113,118],{"type":40,"tag":108,"props":109,"children":110},"td",{},[111],{"type":46,"value":112},"Acceptable latency?",{"type":40,"tag":108,"props":114,"children":115},{},[116],{"type":46,"value":117},"Minutes to hours",{"type":40,"tag":108,"props":119,"children":120},{},[121],{"type":46,"value":122},"Seconds or less",{"type":40,"tag":81,"props":124,"children":125},{},[126,131,136],{"type":40,"tag":108,"props":127,"children":128},{},[129],{"type":46,"value":130},"Throughput trajectory?",{"type":40,"tag":108,"props":132,"children":133},{},[134],{"type":46,"value":135},"Stable or slow-growing",{"type":40,"tag":108,"props":137,"children":138},{},[139],{"type":46,"value":140},"Growing fast or unpredictable",{"type":40,"tag":81,"props":142,"children":143},{},[144,149,154],{"type":40,"tag":108,"props":145,"children":146},{},[147],{"type":46,"value":148},"Failure isolation?",{"type":40,"tag":108,"props":150,"children":151},{},[152],{"type":46,"value":153},"Whole batch can retry",{"type":40,"tag":108,"props":155,"children":156},{},[157],{"type":46,"value":158},"Must handle per-item failure",{"type":40,"tag":81,"props":160,"children":161},{},[162,167,172],{"type":40,"tag":108,"props":163,"children":164},{},[165],{"type":46,"value":166},"Ordering matters?",{"type":40,"tag":108,"props":168,"children":169},{},[170],{"type":46,"value":171},"No, or within batch is fine",{"type":40,"tag":108,"props":173,"children":174},{},[175],{"type":46,"value":176},"Yes, across items",{"type":40,"tag":81,"props":178,"children":179},{},[180,185,190],{"type":40,"tag":108,"props":181,"children":182},{},[183],{"type":46,"value":184},"\"Real-time\" ever mentioned?",{"type":40,"tag":108,"props":186,"children":187},{},[188],{"type":46,"value":189},"No",{"type":40,"tag":108,"props":191,"children":192},{},[193],{"type":46,"value":194},"Yes -- build for it now",{"type":40,"tag":49,"props":196,"children":197},{},[198,203],{"type":40,"tag":55,"props":199,"children":200},{},[201],{"type":46,"value":202},"If the answer to ANY row points to stream, build for streaming from the start.",{"type":46,"value":204}," You cannot cheaply add streaming later.",{"type":40,"tag":61,"props":206,"children":208},{"id":207},"the-rule",[209],{"type":46,"value":210},"The Rule",{"type":40,"tag":49,"props":212,"children":213},{},[214],{"type":46,"value":215},"Reducing a batch interval is not a scaling strategy. A 10-second batch interval is a bad stream processor -- it has all the complexity of streaming with none of the benefits (no ordering, no backpressure, no offset tracking, overlap risk).",{"type":40,"tag":61,"props":217,"children":219},{"id":218},"detection-batch-patterns-that-will-need-streaming",[220],{"type":46,"value":221},"Detection: Batch Patterns That Will Need Streaming",{"type":40,"tag":49,"props":223,"children":224},{},[225],{"type":40,"tag":55,"props":226,"children":227},{},[228],{"type":46,"value":229},"Stop and reassess if you see:",{"type":40,"tag":231,"props":232,"children":233},"ol",{},[234,254,278,288,298],{"type":40,"tag":235,"props":236,"children":237},"li",{},[238,243,245,252],{"type":40,"tag":55,"props":239,"children":240},{},[241],{"type":46,"value":242},"A cron job processing \"new\" or \"unprocessed\" items",{"type":46,"value":244}," -- ",{"type":40,"tag":246,"props":247,"children":249},"code",{"className":248},[],[250],{"type":46,"value":251},"SELECT * FROM events WHERE processed = false",{"type":46,"value":253},". What's the latency requirement? If \"as fast as possible,\" this is the wrong model.",{"type":40,"tag":235,"props":255,"children":256},{},[257,276],{"type":40,"tag":55,"props":258,"children":259},{},[260,266,268,274],{"type":40,"tag":246,"props":261,"children":263},{"className":262},[],[264],{"type":46,"value":265},"setInterval",{"type":46,"value":267}," or ",{"type":40,"tag":246,"props":269,"children":271},{"className":270},[],[272],{"type":46,"value":273},"setTimeout",{"type":46,"value":275}," for processing",{"type":46,"value":277}," -- what happens when processing takes longer than the interval? Overlapping batches cause duplicate processing and resource contention.",{"type":40,"tag":235,"props":279,"children":280},{},[281,286],{"type":40,"tag":55,"props":282,"children":283},{},[284],{"type":46,"value":285},"Shrinking batch intervals over time",{"type":46,"value":287}," -- started at 5 minutes, now at 10 seconds. This is the symptom. The disease is: you need streaming.",{"type":40,"tag":235,"props":289,"children":290},{},[291,296],{"type":40,"tag":55,"props":292,"children":293},{},[294],{"type":46,"value":295},"Items collected into an array before processing",{"type":46,"value":297}," -- what bounds the array? If it's time-based (\"all items in the last 5 minutes\"), memory grows with throughput.",{"type":40,"tag":235,"props":299,"children":300},{},[301,306],{"type":40,"tag":55,"props":302,"children":303},{},[304],{"type":46,"value":305},"\"We'll add real-time later\"",{"type":46,"value":307}," -- flag this immediately. This is not an incremental change. The data flow, error handling, and ordering assumptions are fundamentally different.",{"type":40,"tag":61,"props":309,"children":311},{"id":310},"when-batch-is-correct",[312],{"type":46,"value":313},"When Batch Is Correct",{"type":40,"tag":49,"props":315,"children":316},{},[317],{"type":46,"value":318},"Batch is the right choice when:",{"type":40,"tag":320,"props":321,"children":322},"ul",{},[323,328,333,338],{"type":40,"tag":235,"props":324,"children":325},{},[326],{"type":46,"value":327},"Latency requirements are hours or days (daily reports, nightly ETL, weekly digests)",{"type":40,"tag":235,"props":329,"children":330},{},[331],{"type":46,"value":332},"The processing needs a complete view of a time window (aggregations, reconciliation)",{"type":40,"tag":235,"props":334,"children":335},{},[336],{"type":46,"value":337},"Throughput is stable and predictable",{"type":40,"tag":235,"props":339,"children":340},{},[341],{"type":46,"value":342},"The workload is compute-heavy and benefits from bulk operations (ML training, data export)",{"type":40,"tag":344,"props":345,"children":350},"pre",{"className":346,"code":347,"language":348,"meta":349,"style":349},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F Batch is correct here: daily revenue report. Nobody needs this in real-time.\nasync function generateDailyReport() {\n  const revenue = await db.$queryRaw`\n    SELECT DATE_TRUNC('hour', created_at) as hour, SUM(amount) as total\n    FROM orders\n    WHERE created_at >= ${startOfDay} AND created_at \u003C ${endOfDay}\n    GROUP BY DATE_TRUNC('hour', created_at)\n  `;\n  await saveReport({ date: today, hourlyRevenue: revenue });\n}\n","typescript","",[351],{"type":40,"tag":246,"props":352,"children":353},{"__ignoreMap":349},[354,365,397,442,452,461,504,513,527,599],{"type":40,"tag":355,"props":356,"children":358},"span",{"class":357,"line":27},"line",[359],{"type":40,"tag":355,"props":360,"children":362},{"style":361},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[363],{"type":46,"value":364},"\u002F\u002F Batch is correct here: daily revenue report. Nobody needs this in real-time.\n",{"type":40,"tag":355,"props":366,"children":368},{"class":357,"line":367},2,[369,375,380,386,392],{"type":40,"tag":355,"props":370,"children":372},{"style":371},"--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA",[373],{"type":46,"value":374},"async",{"type":40,"tag":355,"props":376,"children":377},{"style":371},[378],{"type":46,"value":379}," function",{"type":40,"tag":355,"props":381,"children":383},{"style":382},"--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF",[384],{"type":46,"value":385}," generateDailyReport",{"type":40,"tag":355,"props":387,"children":389},{"style":388},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[390],{"type":46,"value":391},"()",{"type":40,"tag":355,"props":393,"children":394},{"style":388},[395],{"type":46,"value":396}," {\n",{"type":40,"tag":355,"props":398,"children":399},{"class":357,"line":23},[400,405,411,416,422,427,432,437],{"type":40,"tag":355,"props":401,"children":402},{"style":371},[403],{"type":46,"value":404},"  const",{"type":40,"tag":355,"props":406,"children":408},{"style":407},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[409],{"type":46,"value":410}," revenue",{"type":40,"tag":355,"props":412,"children":413},{"style":388},[414],{"type":46,"value":415}," =",{"type":40,"tag":355,"props":417,"children":419},{"style":418},"--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic",[420],{"type":46,"value":421}," await",{"type":40,"tag":355,"props":423,"children":424},{"style":407},[425],{"type":46,"value":426}," db",{"type":40,"tag":355,"props":428,"children":429},{"style":388},[430],{"type":46,"value":431},".",{"type":40,"tag":355,"props":433,"children":434},{"style":382},[435],{"type":46,"value":436},"$queryRaw",{"type":40,"tag":355,"props":438,"children":439},{"style":388},[440],{"type":46,"value":441},"`\n",{"type":40,"tag":355,"props":443,"children":445},{"class":357,"line":444},4,[446],{"type":40,"tag":355,"props":447,"children":449},{"style":448},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[450],{"type":46,"value":451},"    SELECT DATE_TRUNC('hour', created_at) as hour, SUM(amount) as total\n",{"type":40,"tag":355,"props":453,"children":455},{"class":357,"line":454},5,[456],{"type":40,"tag":355,"props":457,"children":458},{"style":448},[459],{"type":46,"value":460},"    FROM orders\n",{"type":40,"tag":355,"props":462,"children":464},{"class":357,"line":463},6,[465,470,475,480,485,490,494,499],{"type":40,"tag":355,"props":466,"children":467},{"style":448},[468],{"type":46,"value":469},"    WHERE created_at >= ",{"type":40,"tag":355,"props":471,"children":472},{"style":388},[473],{"type":46,"value":474},"${",{"type":40,"tag":355,"props":476,"children":477},{"style":407},[478],{"type":46,"value":479},"startOfDay",{"type":40,"tag":355,"props":481,"children":482},{"style":388},[483],{"type":46,"value":484},"}",{"type":40,"tag":355,"props":486,"children":487},{"style":448},[488],{"type":46,"value":489}," AND created_at \u003C ",{"type":40,"tag":355,"props":491,"children":492},{"style":388},[493],{"type":46,"value":474},{"type":40,"tag":355,"props":495,"children":496},{"style":407},[497],{"type":46,"value":498},"endOfDay",{"type":40,"tag":355,"props":500,"children":501},{"style":388},[502],{"type":46,"value":503},"}\n",{"type":40,"tag":355,"props":505,"children":507},{"class":357,"line":506},7,[508],{"type":40,"tag":355,"props":509,"children":510},{"style":448},[511],{"type":46,"value":512},"    GROUP BY DATE_TRUNC('hour', created_at)\n",{"type":40,"tag":355,"props":514,"children":516},{"class":357,"line":515},8,[517,522],{"type":40,"tag":355,"props":518,"children":519},{"style":388},[520],{"type":46,"value":521},"  `",{"type":40,"tag":355,"props":523,"children":524},{"style":388},[525],{"type":46,"value":526},";\n",{"type":40,"tag":355,"props":528,"children":530},{"class":357,"line":529},9,[531,536,541,547,552,557,562,567,572,577,581,585,590,595],{"type":40,"tag":355,"props":532,"children":533},{"style":418},[534],{"type":46,"value":535},"  await",{"type":40,"tag":355,"props":537,"children":538},{"style":382},[539],{"type":46,"value":540}," saveReport",{"type":40,"tag":355,"props":542,"children":544},{"style":543},"--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178",[545],{"type":46,"value":546},"(",{"type":40,"tag":355,"props":548,"children":549},{"style":388},[550],{"type":46,"value":551},"{",{"type":40,"tag":355,"props":553,"children":554},{"style":543},[555],{"type":46,"value":556}," date",{"type":40,"tag":355,"props":558,"children":559},{"style":388},[560],{"type":46,"value":561},":",{"type":40,"tag":355,"props":563,"children":564},{"style":407},[565],{"type":46,"value":566}," today",{"type":40,"tag":355,"props":568,"children":569},{"style":388},[570],{"type":46,"value":571},",",{"type":40,"tag":355,"props":573,"children":574},{"style":543},[575],{"type":46,"value":576}," hourlyRevenue",{"type":40,"tag":355,"props":578,"children":579},{"style":388},[580],{"type":46,"value":561},{"type":40,"tag":355,"props":582,"children":583},{"style":407},[584],{"type":46,"value":410},{"type":40,"tag":355,"props":586,"children":587},{"style":388},[588],{"type":46,"value":589}," }",{"type":40,"tag":355,"props":591,"children":592},{"style":543},[593],{"type":46,"value":594},")",{"type":40,"tag":355,"props":596,"children":597},{"style":388},[598],{"type":46,"value":526},{"type":40,"tag":355,"props":600,"children":602},{"class":357,"line":601},10,[603],{"type":40,"tag":355,"props":604,"children":605},{"style":388},[606],{"type":46,"value":503},{"type":40,"tag":61,"props":608,"children":610},{"id":609},"when-you-need-event-driven-processing",[611],{"type":46,"value":612},"When You Need Event-Driven Processing",{"type":40,"tag":49,"props":614,"children":615},{},[616],{"type":46,"value":617},"For most applications, you don't need Kafka. You need event-driven task processing with proper failure handling.",{"type":40,"tag":344,"props":619,"children":621},{"className":346,"code":620,"language":348,"meta":349,"style":349},"\u002F\u002F Process each item as it arrives. Failure isolated per item.\n\u002F\u002F Latency is seconds, not minutes. Scales by adding workers.\nimport { task } from \"@trigger.dev\u002Fsdk\";\n\nexport const processSignup = task({\n  id: \"process-signup\",\n  retry: { maxAttempts: 3 },\n  run: async (payload: { userId: string }) => {\n    const user = await db.user.findUnique({ where: { id: payload.userId } });\n    await sendWelcomeEmail(user);\n    await createDefaultWorkspace(user);\n    await trackSignupAnalytics(user);\n  },\n});\n\n\u002F\u002F In the signup handler -- trigger immediately, don't batch\nasync function handleSignup(data: SignupInput) {\n  const user = await db.user.create({ data });\n  await processSignup.trigger({ userId: user.id });\n  return user;\n}\n",[622],{"type":40,"tag":246,"props":623,"children":624},{"__ignoreMap":349},[625,633,641,687,696,732,762,798,863,966,995,1024,1053,1062,1078,1086,1095,1138,1204,1267,1284],{"type":40,"tag":355,"props":626,"children":627},{"class":357,"line":27},[628],{"type":40,"tag":355,"props":629,"children":630},{"style":361},[631],{"type":46,"value":632},"\u002F\u002F Process each item as it arrives. Failure isolated per item.\n",{"type":40,"tag":355,"props":634,"children":635},{"class":357,"line":367},[636],{"type":40,"tag":355,"props":637,"children":638},{"style":361},[639],{"type":46,"value":640},"\u002F\u002F Latency is seconds, not minutes. Scales by adding workers.\n",{"type":40,"tag":355,"props":642,"children":643},{"class":357,"line":23},[644,649,654,659,663,668,673,678,683],{"type":40,"tag":355,"props":645,"children":646},{"style":418},[647],{"type":46,"value":648},"import",{"type":40,"tag":355,"props":650,"children":651},{"style":388},[652],{"type":46,"value":653}," {",{"type":40,"tag":355,"props":655,"children":656},{"style":407},[657],{"type":46,"value":658}," task",{"type":40,"tag":355,"props":660,"children":661},{"style":388},[662],{"type":46,"value":589},{"type":40,"tag":355,"props":664,"children":665},{"style":418},[666],{"type":46,"value":667}," from",{"type":40,"tag":355,"props":669,"children":670},{"style":388},[671],{"type":46,"value":672}," \"",{"type":40,"tag":355,"props":674,"children":675},{"style":448},[676],{"type":46,"value":677},"@trigger.dev\u002Fsdk",{"type":40,"tag":355,"props":679,"children":680},{"style":388},[681],{"type":46,"value":682},"\"",{"type":40,"tag":355,"props":684,"children":685},{"style":388},[686],{"type":46,"value":526},{"type":40,"tag":355,"props":688,"children":689},{"class":357,"line":444},[690],{"type":40,"tag":355,"props":691,"children":693},{"emptyLinePlaceholder":692},true,[694],{"type":46,"value":695},"\n",{"type":40,"tag":355,"props":697,"children":698},{"class":357,"line":454},[699,704,709,714,719,723,727],{"type":40,"tag":355,"props":700,"children":701},{"style":418},[702],{"type":46,"value":703},"export",{"type":40,"tag":355,"props":705,"children":706},{"style":371},[707],{"type":46,"value":708}," const",{"type":40,"tag":355,"props":710,"children":711},{"style":407},[712],{"type":46,"value":713}," processSignup ",{"type":40,"tag":355,"props":715,"children":716},{"style":388},[717],{"type":46,"value":718},"=",{"type":40,"tag":355,"props":720,"children":721},{"style":382},[722],{"type":46,"value":658},{"type":40,"tag":355,"props":724,"children":725},{"style":407},[726],{"type":46,"value":546},{"type":40,"tag":355,"props":728,"children":729},{"style":388},[730],{"type":46,"value":731},"{\n",{"type":40,"tag":355,"props":733,"children":734},{"class":357,"line":463},[735,740,744,748,753,757],{"type":40,"tag":355,"props":736,"children":737},{"style":543},[738],{"type":46,"value":739},"  id",{"type":40,"tag":355,"props":741,"children":742},{"style":388},[743],{"type":46,"value":561},{"type":40,"tag":355,"props":745,"children":746},{"style":388},[747],{"type":46,"value":672},{"type":40,"tag":355,"props":749,"children":750},{"style":448},[751],{"type":46,"value":752},"process-signup",{"type":40,"tag":355,"props":754,"children":755},{"style":388},[756],{"type":46,"value":682},{"type":40,"tag":355,"props":758,"children":759},{"style":388},[760],{"type":46,"value":761},",\n",{"type":40,"tag":355,"props":763,"children":764},{"class":357,"line":506},[765,770,774,778,783,787,793],{"type":40,"tag":355,"props":766,"children":767},{"style":543},[768],{"type":46,"value":769},"  retry",{"type":40,"tag":355,"props":771,"children":772},{"style":388},[773],{"type":46,"value":561},{"type":40,"tag":355,"props":775,"children":776},{"style":388},[777],{"type":46,"value":653},{"type":40,"tag":355,"props":779,"children":780},{"style":543},[781],{"type":46,"value":782}," maxAttempts",{"type":40,"tag":355,"props":784,"children":785},{"style":388},[786],{"type":46,"value":561},{"type":40,"tag":355,"props":788,"children":790},{"style":789},"--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C",[791],{"type":46,"value":792}," 3",{"type":40,"tag":355,"props":794,"children":795},{"style":388},[796],{"type":46,"value":797}," },\n",{"type":40,"tag":355,"props":799,"children":800},{"class":357,"line":515},[801,806,810,815,820,826,830,834,839,843,849,854,859],{"type":40,"tag":355,"props":802,"children":803},{"style":382},[804],{"type":46,"value":805},"  run",{"type":40,"tag":355,"props":807,"children":808},{"style":388},[809],{"type":46,"value":561},{"type":40,"tag":355,"props":811,"children":812},{"style":371},[813],{"type":46,"value":814}," async",{"type":40,"tag":355,"props":816,"children":817},{"style":388},[818],{"type":46,"value":819}," (",{"type":40,"tag":355,"props":821,"children":823},{"style":822},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic",[824],{"type":46,"value":825},"payload",{"type":40,"tag":355,"props":827,"children":828},{"style":388},[829],{"type":46,"value":561},{"type":40,"tag":355,"props":831,"children":832},{"style":388},[833],{"type":46,"value":653},{"type":40,"tag":355,"props":835,"children":836},{"style":543},[837],{"type":46,"value":838}," userId",{"type":40,"tag":355,"props":840,"children":841},{"style":388},[842],{"type":46,"value":561},{"type":40,"tag":355,"props":844,"children":846},{"style":845},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[847],{"type":46,"value":848}," string",{"type":40,"tag":355,"props":850,"children":851},{"style":388},[852],{"type":46,"value":853}," })",{"type":40,"tag":355,"props":855,"children":856},{"style":371},[857],{"type":46,"value":858}," =>",{"type":40,"tag":355,"props":860,"children":861},{"style":388},[862],{"type":46,"value":396},{"type":40,"tag":355,"props":864,"children":865},{"class":357,"line":529},[866,871,876,880,884,888,892,897,901,906,910,914,919,923,927,932,936,941,945,950,954,958,962],{"type":40,"tag":355,"props":867,"children":868},{"style":371},[869],{"type":46,"value":870},"    const",{"type":40,"tag":355,"props":872,"children":873},{"style":407},[874],{"type":46,"value":875}," user",{"type":40,"tag":355,"props":877,"children":878},{"style":388},[879],{"type":46,"value":415},{"type":40,"tag":355,"props":881,"children":882},{"style":418},[883],{"type":46,"value":421},{"type":40,"tag":355,"props":885,"children":886},{"style":407},[887],{"type":46,"value":426},{"type":40,"tag":355,"props":889,"children":890},{"style":388},[891],{"type":46,"value":431},{"type":40,"tag":355,"props":893,"children":894},{"style":407},[895],{"type":46,"value":896},"user",{"type":40,"tag":355,"props":898,"children":899},{"style":388},[900],{"type":46,"value":431},{"type":40,"tag":355,"props":902,"children":903},{"style":382},[904],{"type":46,"value":905},"findUnique",{"type":40,"tag":355,"props":907,"children":908},{"style":543},[909],{"type":46,"value":546},{"type":40,"tag":355,"props":911,"children":912},{"style":388},[913],{"type":46,"value":551},{"type":40,"tag":355,"props":915,"children":916},{"style":543},[917],{"type":46,"value":918}," where",{"type":40,"tag":355,"props":920,"children":921},{"style":388},[922],{"type":46,"value":561},{"type":40,"tag":355,"props":924,"children":925},{"style":388},[926],{"type":46,"value":653},{"type":40,"tag":355,"props":928,"children":929},{"style":543},[930],{"type":46,"value":931}," id",{"type":40,"tag":355,"props":933,"children":934},{"style":388},[935],{"type":46,"value":561},{"type":40,"tag":355,"props":937,"children":938},{"style":407},[939],{"type":46,"value":940}," payload",{"type":40,"tag":355,"props":942,"children":943},{"style":388},[944],{"type":46,"value":431},{"type":40,"tag":355,"props":946,"children":947},{"style":407},[948],{"type":46,"value":949},"userId",{"type":40,"tag":355,"props":951,"children":952},{"style":388},[953],{"type":46,"value":589},{"type":40,"tag":355,"props":955,"children":956},{"style":388},[957],{"type":46,"value":589},{"type":40,"tag":355,"props":959,"children":960},{"style":543},[961],{"type":46,"value":594},{"type":40,"tag":355,"props":963,"children":964},{"style":388},[965],{"type":46,"value":526},{"type":40,"tag":355,"props":967,"children":968},{"class":357,"line":601},[969,974,979,983,987,991],{"type":40,"tag":355,"props":970,"children":971},{"style":418},[972],{"type":46,"value":973},"    await",{"type":40,"tag":355,"props":975,"children":976},{"style":382},[977],{"type":46,"value":978}," sendWelcomeEmail",{"type":40,"tag":355,"props":980,"children":981},{"style":543},[982],{"type":46,"value":546},{"type":40,"tag":355,"props":984,"children":985},{"style":407},[986],{"type":46,"value":896},{"type":40,"tag":355,"props":988,"children":989},{"style":543},[990],{"type":46,"value":594},{"type":40,"tag":355,"props":992,"children":993},{"style":388},[994],{"type":46,"value":526},{"type":40,"tag":355,"props":996,"children":998},{"class":357,"line":997},11,[999,1003,1008,1012,1016,1020],{"type":40,"tag":355,"props":1000,"children":1001},{"style":418},[1002],{"type":46,"value":973},{"type":40,"tag":355,"props":1004,"children":1005},{"style":382},[1006],{"type":46,"value":1007}," createDefaultWorkspace",{"type":40,"tag":355,"props":1009,"children":1010},{"style":543},[1011],{"type":46,"value":546},{"type":40,"tag":355,"props":1013,"children":1014},{"style":407},[1015],{"type":46,"value":896},{"type":40,"tag":355,"props":1017,"children":1018},{"style":543},[1019],{"type":46,"value":594},{"type":40,"tag":355,"props":1021,"children":1022},{"style":388},[1023],{"type":46,"value":526},{"type":40,"tag":355,"props":1025,"children":1027},{"class":357,"line":1026},12,[1028,1032,1037,1041,1045,1049],{"type":40,"tag":355,"props":1029,"children":1030},{"style":418},[1031],{"type":46,"value":973},{"type":40,"tag":355,"props":1033,"children":1034},{"style":382},[1035],{"type":46,"value":1036}," trackSignupAnalytics",{"type":40,"tag":355,"props":1038,"children":1039},{"style":543},[1040],{"type":46,"value":546},{"type":40,"tag":355,"props":1042,"children":1043},{"style":407},[1044],{"type":46,"value":896},{"type":40,"tag":355,"props":1046,"children":1047},{"style":543},[1048],{"type":46,"value":594},{"type":40,"tag":355,"props":1050,"children":1051},{"style":388},[1052],{"type":46,"value":526},{"type":40,"tag":355,"props":1054,"children":1056},{"class":357,"line":1055},13,[1057],{"type":40,"tag":355,"props":1058,"children":1059},{"style":388},[1060],{"type":46,"value":1061},"  },\n",{"type":40,"tag":355,"props":1063,"children":1065},{"class":357,"line":1064},14,[1066,1070,1074],{"type":40,"tag":355,"props":1067,"children":1068},{"style":388},[1069],{"type":46,"value":484},{"type":40,"tag":355,"props":1071,"children":1072},{"style":407},[1073],{"type":46,"value":594},{"type":40,"tag":355,"props":1075,"children":1076},{"style":388},[1077],{"type":46,"value":526},{"type":40,"tag":355,"props":1079,"children":1081},{"class":357,"line":1080},15,[1082],{"type":40,"tag":355,"props":1083,"children":1084},{"emptyLinePlaceholder":692},[1085],{"type":46,"value":695},{"type":40,"tag":355,"props":1087,"children":1089},{"class":357,"line":1088},16,[1090],{"type":40,"tag":355,"props":1091,"children":1092},{"style":361},[1093],{"type":46,"value":1094},"\u002F\u002F In the signup handler -- trigger immediately, don't batch\n",{"type":40,"tag":355,"props":1096,"children":1098},{"class":357,"line":1097},17,[1099,1103,1107,1112,1116,1121,1125,1130,1134],{"type":40,"tag":355,"props":1100,"children":1101},{"style":371},[1102],{"type":46,"value":374},{"type":40,"tag":355,"props":1104,"children":1105},{"style":371},[1106],{"type":46,"value":379},{"type":40,"tag":355,"props":1108,"children":1109},{"style":382},[1110],{"type":46,"value":1111}," handleSignup",{"type":40,"tag":355,"props":1113,"children":1114},{"style":388},[1115],{"type":46,"value":546},{"type":40,"tag":355,"props":1117,"children":1118},{"style":822},[1119],{"type":46,"value":1120},"data",{"type":40,"tag":355,"props":1122,"children":1123},{"style":388},[1124],{"type":46,"value":561},{"type":40,"tag":355,"props":1126,"children":1127},{"style":845},[1128],{"type":46,"value":1129}," SignupInput",{"type":40,"tag":355,"props":1131,"children":1132},{"style":388},[1133],{"type":46,"value":594},{"type":40,"tag":355,"props":1135,"children":1136},{"style":388},[1137],{"type":46,"value":396},{"type":40,"tag":355,"props":1139,"children":1141},{"class":357,"line":1140},18,[1142,1146,1150,1154,1158,1162,1166,1170,1174,1179,1183,1187,1192,1196,1200],{"type":40,"tag":355,"props":1143,"children":1144},{"style":371},[1145],{"type":46,"value":404},{"type":40,"tag":355,"props":1147,"children":1148},{"style":407},[1149],{"type":46,"value":875},{"type":40,"tag":355,"props":1151,"children":1152},{"style":388},[1153],{"type":46,"value":415},{"type":40,"tag":355,"props":1155,"children":1156},{"style":418},[1157],{"type":46,"value":421},{"type":40,"tag":355,"props":1159,"children":1160},{"style":407},[1161],{"type":46,"value":426},{"type":40,"tag":355,"props":1163,"children":1164},{"style":388},[1165],{"type":46,"value":431},{"type":40,"tag":355,"props":1167,"children":1168},{"style":407},[1169],{"type":46,"value":896},{"type":40,"tag":355,"props":1171,"children":1172},{"style":388},[1173],{"type":46,"value":431},{"type":40,"tag":355,"props":1175,"children":1176},{"style":382},[1177],{"type":46,"value":1178},"create",{"type":40,"tag":355,"props":1180,"children":1181},{"style":543},[1182],{"type":46,"value":546},{"type":40,"tag":355,"props":1184,"children":1185},{"style":388},[1186],{"type":46,"value":551},{"type":40,"tag":355,"props":1188,"children":1189},{"style":407},[1190],{"type":46,"value":1191}," data",{"type":40,"tag":355,"props":1193,"children":1194},{"style":388},[1195],{"type":46,"value":589},{"type":40,"tag":355,"props":1197,"children":1198},{"style":543},[1199],{"type":46,"value":594},{"type":40,"tag":355,"props":1201,"children":1202},{"style":388},[1203],{"type":46,"value":526},{"type":40,"tag":355,"props":1205,"children":1207},{"class":357,"line":1206},19,[1208,1212,1217,1221,1226,1230,1234,1238,1242,1246,1250,1255,1259,1263],{"type":40,"tag":355,"props":1209,"children":1210},{"style":418},[1211],{"type":46,"value":535},{"type":40,"tag":355,"props":1213,"children":1214},{"style":407},[1215],{"type":46,"value":1216}," processSignup",{"type":40,"tag":355,"props":1218,"children":1219},{"style":388},[1220],{"type":46,"value":431},{"type":40,"tag":355,"props":1222,"children":1223},{"style":382},[1224],{"type":46,"value":1225},"trigger",{"type":40,"tag":355,"props":1227,"children":1228},{"style":543},[1229],{"type":46,"value":546},{"type":40,"tag":355,"props":1231,"children":1232},{"style":388},[1233],{"type":46,"value":551},{"type":40,"tag":355,"props":1235,"children":1236},{"style":543},[1237],{"type":46,"value":838},{"type":40,"tag":355,"props":1239,"children":1240},{"style":388},[1241],{"type":46,"value":561},{"type":40,"tag":355,"props":1243,"children":1244},{"style":407},[1245],{"type":46,"value":875},{"type":40,"tag":355,"props":1247,"children":1248},{"style":388},[1249],{"type":46,"value":431},{"type":40,"tag":355,"props":1251,"children":1252},{"style":407},[1253],{"type":46,"value":1254},"id",{"type":40,"tag":355,"props":1256,"children":1257},{"style":388},[1258],{"type":46,"value":589},{"type":40,"tag":355,"props":1260,"children":1261},{"style":543},[1262],{"type":46,"value":594},{"type":40,"tag":355,"props":1264,"children":1265},{"style":388},[1266],{"type":46,"value":526},{"type":40,"tag":355,"props":1268,"children":1270},{"class":357,"line":1269},20,[1271,1276,1280],{"type":40,"tag":355,"props":1272,"children":1273},{"style":418},[1274],{"type":46,"value":1275},"  return",{"type":40,"tag":355,"props":1277,"children":1278},{"style":407},[1279],{"type":46,"value":875},{"type":40,"tag":355,"props":1281,"children":1282},{"style":388},[1283],{"type":46,"value":526},{"type":40,"tag":355,"props":1285,"children":1287},{"class":357,"line":1286},21,[1288],{"type":40,"tag":355,"props":1289,"children":1290},{"style":388},[1291],{"type":46,"value":503},{"type":40,"tag":61,"props":1293,"children":1295},{"id":1294},"micro-batching-the-middle-ground",[1296],{"type":46,"value":1297},"Micro-Batching: The Middle Ground",{"type":40,"tag":49,"props":1299,"children":1300},{},[1301],{"type":46,"value":1302},"When per-item overhead is too high but you need low latency, use small frequent batches with per-item failure handling.",{"type":40,"tag":344,"props":1304,"children":1306},{"className":346,"code":1305,"language":348,"meta":349,"style":349},"import { task } from \"@trigger.dev\u002Fsdk\";\n\nexport const processEventBatch = task({\n  id: \"process-event-batch\",\n  queue: { concurrencyLimit: 5 },\n  run: async (payload: { eventIds: string[] }) => {\n    const events = await db.event.findMany({\n      where: { id: { in: payload.eventIds } },\n    });\n\n    \u002F\u002F Process individually within the batch -- failure isolation\n    const results = await Promise.allSettled(\n      events.map(event => processEvent(event))\n    );\n\n    \u002F\u002F Retry only failures, not the whole batch\n    const failures = results\n      .map((r, i) => r.status === \"rejected\" ? events[i] : null)\n      .filter(Boolean);\n    if (failures.length > 0) await enqueueRetry(failures);\n  },\n});\n",[1307],{"type":40,"tag":246,"props":1308,"children":1309},{"__ignoreMap":349},[1310,1349,1356,1388,1416,1450,1512,1562,1620,1636,1643,1651,1690,1737,1749,1756,1764,1785,1897,1926,1993,2000],{"type":40,"tag":355,"props":1311,"children":1312},{"class":357,"line":27},[1313,1317,1321,1325,1329,1333,1337,1341,1345],{"type":40,"tag":355,"props":1314,"children":1315},{"style":418},[1316],{"type":46,"value":648},{"type":40,"tag":355,"props":1318,"children":1319},{"style":388},[1320],{"type":46,"value":653},{"type":40,"tag":355,"props":1322,"children":1323},{"style":407},[1324],{"type":46,"value":658},{"type":40,"tag":355,"props":1326,"children":1327},{"style":388},[1328],{"type":46,"value":589},{"type":40,"tag":355,"props":1330,"children":1331},{"style":418},[1332],{"type":46,"value":667},{"type":40,"tag":355,"props":1334,"children":1335},{"style":388},[1336],{"type":46,"value":672},{"type":40,"tag":355,"props":1338,"children":1339},{"style":448},[1340],{"type":46,"value":677},{"type":40,"tag":355,"props":1342,"children":1343},{"style":388},[1344],{"type":46,"value":682},{"type":40,"tag":355,"props":1346,"children":1347},{"style":388},[1348],{"type":46,"value":526},{"type":40,"tag":355,"props":1350,"children":1351},{"class":357,"line":367},[1352],{"type":40,"tag":355,"props":1353,"children":1354},{"emptyLinePlaceholder":692},[1355],{"type":46,"value":695},{"type":40,"tag":355,"props":1357,"children":1358},{"class":357,"line":23},[1359,1363,1367,1372,1376,1380,1384],{"type":40,"tag":355,"props":1360,"children":1361},{"style":418},[1362],{"type":46,"value":703},{"type":40,"tag":355,"props":1364,"children":1365},{"style":371},[1366],{"type":46,"value":708},{"type":40,"tag":355,"props":1368,"children":1369},{"style":407},[1370],{"type":46,"value":1371}," processEventBatch ",{"type":40,"tag":355,"props":1373,"children":1374},{"style":388},[1375],{"type":46,"value":718},{"type":40,"tag":355,"props":1377,"children":1378},{"style":382},[1379],{"type":46,"value":658},{"type":40,"tag":355,"props":1381,"children":1382},{"style":407},[1383],{"type":46,"value":546},{"type":40,"tag":355,"props":1385,"children":1386},{"style":388},[1387],{"type":46,"value":731},{"type":40,"tag":355,"props":1389,"children":1390},{"class":357,"line":444},[1391,1395,1399,1403,1408,1412],{"type":40,"tag":355,"props":1392,"children":1393},{"style":543},[1394],{"type":46,"value":739},{"type":40,"tag":355,"props":1396,"children":1397},{"style":388},[1398],{"type":46,"value":561},{"type":40,"tag":355,"props":1400,"children":1401},{"style":388},[1402],{"type":46,"value":672},{"type":40,"tag":355,"props":1404,"children":1405},{"style":448},[1406],{"type":46,"value":1407},"process-event-batch",{"type":40,"tag":355,"props":1409,"children":1410},{"style":388},[1411],{"type":46,"value":682},{"type":40,"tag":355,"props":1413,"children":1414},{"style":388},[1415],{"type":46,"value":761},{"type":40,"tag":355,"props":1417,"children":1418},{"class":357,"line":454},[1419,1424,1428,1432,1437,1441,1446],{"type":40,"tag":355,"props":1420,"children":1421},{"style":543},[1422],{"type":46,"value":1423},"  queue",{"type":40,"tag":355,"props":1425,"children":1426},{"style":388},[1427],{"type":46,"value":561},{"type":40,"tag":355,"props":1429,"children":1430},{"style":388},[1431],{"type":46,"value":653},{"type":40,"tag":355,"props":1433,"children":1434},{"style":543},[1435],{"type":46,"value":1436}," concurrencyLimit",{"type":40,"tag":355,"props":1438,"children":1439},{"style":388},[1440],{"type":46,"value":561},{"type":40,"tag":355,"props":1442,"children":1443},{"style":789},[1444],{"type":46,"value":1445}," 5",{"type":40,"tag":355,"props":1447,"children":1448},{"style":388},[1449],{"type":46,"value":797},{"type":40,"tag":355,"props":1451,"children":1452},{"class":357,"line":463},[1453,1457,1461,1465,1469,1473,1477,1481,1486,1490,1494,1499,1504,1508],{"type":40,"tag":355,"props":1454,"children":1455},{"style":382},[1456],{"type":46,"value":805},{"type":40,"tag":355,"props":1458,"children":1459},{"style":388},[1460],{"type":46,"value":561},{"type":40,"tag":355,"props":1462,"children":1463},{"style":371},[1464],{"type":46,"value":814},{"type":40,"tag":355,"props":1466,"children":1467},{"style":388},[1468],{"type":46,"value":819},{"type":40,"tag":355,"props":1470,"children":1471},{"style":822},[1472],{"type":46,"value":825},{"type":40,"tag":355,"props":1474,"children":1475},{"style":388},[1476],{"type":46,"value":561},{"type":40,"tag":355,"props":1478,"children":1479},{"style":388},[1480],{"type":46,"value":653},{"type":40,"tag":355,"props":1482,"children":1483},{"style":543},[1484],{"type":46,"value":1485}," eventIds",{"type":40,"tag":355,"props":1487,"children":1488},{"style":388},[1489],{"type":46,"value":561},{"type":40,"tag":355,"props":1491,"children":1492},{"style":845},[1493],{"type":46,"value":848},{"type":40,"tag":355,"props":1495,"children":1496},{"style":407},[1497],{"type":46,"value":1498},"[] ",{"type":40,"tag":355,"props":1500,"children":1501},{"style":388},[1502],{"type":46,"value":1503},"})",{"type":40,"tag":355,"props":1505,"children":1506},{"style":371},[1507],{"type":46,"value":858},{"type":40,"tag":355,"props":1509,"children":1510},{"style":388},[1511],{"type":46,"value":396},{"type":40,"tag":355,"props":1513,"children":1514},{"class":357,"line":506},[1515,1519,1524,1528,1532,1536,1540,1545,1549,1554,1558],{"type":40,"tag":355,"props":1516,"children":1517},{"style":371},[1518],{"type":46,"value":870},{"type":40,"tag":355,"props":1520,"children":1521},{"style":407},[1522],{"type":46,"value":1523}," events",{"type":40,"tag":355,"props":1525,"children":1526},{"style":388},[1527],{"type":46,"value":415},{"type":40,"tag":355,"props":1529,"children":1530},{"style":418},[1531],{"type":46,"value":421},{"type":40,"tag":355,"props":1533,"children":1534},{"style":407},[1535],{"type":46,"value":426},{"type":40,"tag":355,"props":1537,"children":1538},{"style":388},[1539],{"type":46,"value":431},{"type":40,"tag":355,"props":1541,"children":1542},{"style":407},[1543],{"type":46,"value":1544},"event",{"type":40,"tag":355,"props":1546,"children":1547},{"style":388},[1548],{"type":46,"value":431},{"type":40,"tag":355,"props":1550,"children":1551},{"style":382},[1552],{"type":46,"value":1553},"findMany",{"type":40,"tag":355,"props":1555,"children":1556},{"style":543},[1557],{"type":46,"value":546},{"type":40,"tag":355,"props":1559,"children":1560},{"style":388},[1561],{"type":46,"value":731},{"type":40,"tag":355,"props":1563,"children":1564},{"class":357,"line":515},[1565,1570,1574,1578,1582,1586,1590,1595,1599,1603,1607,1612,1616],{"type":40,"tag":355,"props":1566,"children":1567},{"style":543},[1568],{"type":46,"value":1569},"      where",{"type":40,"tag":355,"props":1571,"children":1572},{"style":388},[1573],{"type":46,"value":561},{"type":40,"tag":355,"props":1575,"children":1576},{"style":388},[1577],{"type":46,"value":653},{"type":40,"tag":355,"props":1579,"children":1580},{"style":543},[1581],{"type":46,"value":931},{"type":40,"tag":355,"props":1583,"children":1584},{"style":388},[1585],{"type":46,"value":561},{"type":40,"tag":355,"props":1587,"children":1588},{"style":388},[1589],{"type":46,"value":653},{"type":40,"tag":355,"props":1591,"children":1592},{"style":543},[1593],{"type":46,"value":1594}," in",{"type":40,"tag":355,"props":1596,"children":1597},{"style":388},[1598],{"type":46,"value":561},{"type":40,"tag":355,"props":1600,"children":1601},{"style":407},[1602],{"type":46,"value":940},{"type":40,"tag":355,"props":1604,"children":1605},{"style":388},[1606],{"type":46,"value":431},{"type":40,"tag":355,"props":1608,"children":1609},{"style":407},[1610],{"type":46,"value":1611},"eventIds",{"type":40,"tag":355,"props":1613,"children":1614},{"style":388},[1615],{"type":46,"value":589},{"type":40,"tag":355,"props":1617,"children":1618},{"style":388},[1619],{"type":46,"value":797},{"type":40,"tag":355,"props":1621,"children":1622},{"class":357,"line":529},[1623,1628,1632],{"type":40,"tag":355,"props":1624,"children":1625},{"style":388},[1626],{"type":46,"value":1627},"    }",{"type":40,"tag":355,"props":1629,"children":1630},{"style":543},[1631],{"type":46,"value":594},{"type":40,"tag":355,"props":1633,"children":1634},{"style":388},[1635],{"type":46,"value":526},{"type":40,"tag":355,"props":1637,"children":1638},{"class":357,"line":601},[1639],{"type":40,"tag":355,"props":1640,"children":1641},{"emptyLinePlaceholder":692},[1642],{"type":46,"value":695},{"type":40,"tag":355,"props":1644,"children":1645},{"class":357,"line":997},[1646],{"type":40,"tag":355,"props":1647,"children":1648},{"style":361},[1649],{"type":46,"value":1650},"    \u002F\u002F Process individually within the batch -- failure isolation\n",{"type":40,"tag":355,"props":1652,"children":1653},{"class":357,"line":1026},[1654,1658,1663,1667,1671,1676,1680,1685],{"type":40,"tag":355,"props":1655,"children":1656},{"style":371},[1657],{"type":46,"value":870},{"type":40,"tag":355,"props":1659,"children":1660},{"style":407},[1661],{"type":46,"value":1662}," results",{"type":40,"tag":355,"props":1664,"children":1665},{"style":388},[1666],{"type":46,"value":415},{"type":40,"tag":355,"props":1668,"children":1669},{"style":418},[1670],{"type":46,"value":421},{"type":40,"tag":355,"props":1672,"children":1673},{"style":845},[1674],{"type":46,"value":1675}," Promise",{"type":40,"tag":355,"props":1677,"children":1678},{"style":388},[1679],{"type":46,"value":431},{"type":40,"tag":355,"props":1681,"children":1682},{"style":382},[1683],{"type":46,"value":1684},"allSettled",{"type":40,"tag":355,"props":1686,"children":1687},{"style":543},[1688],{"type":46,"value":1689},"(\n",{"type":40,"tag":355,"props":1691,"children":1692},{"class":357,"line":1055},[1693,1698,1702,1707,1711,1715,1719,1724,1728,1732],{"type":40,"tag":355,"props":1694,"children":1695},{"style":407},[1696],{"type":46,"value":1697},"      events",{"type":40,"tag":355,"props":1699,"children":1700},{"style":388},[1701],{"type":46,"value":431},{"type":40,"tag":355,"props":1703,"children":1704},{"style":382},[1705],{"type":46,"value":1706},"map",{"type":40,"tag":355,"props":1708,"children":1709},{"style":543},[1710],{"type":46,"value":546},{"type":40,"tag":355,"props":1712,"children":1713},{"style":822},[1714],{"type":46,"value":1544},{"type":40,"tag":355,"props":1716,"children":1717},{"style":371},[1718],{"type":46,"value":858},{"type":40,"tag":355,"props":1720,"children":1721},{"style":382},[1722],{"type":46,"value":1723}," processEvent",{"type":40,"tag":355,"props":1725,"children":1726},{"style":543},[1727],{"type":46,"value":546},{"type":40,"tag":355,"props":1729,"children":1730},{"style":407},[1731],{"type":46,"value":1544},{"type":40,"tag":355,"props":1733,"children":1734},{"style":543},[1735],{"type":46,"value":1736},"))\n",{"type":40,"tag":355,"props":1738,"children":1739},{"class":357,"line":1064},[1740,1745],{"type":40,"tag":355,"props":1741,"children":1742},{"style":543},[1743],{"type":46,"value":1744},"    )",{"type":40,"tag":355,"props":1746,"children":1747},{"style":388},[1748],{"type":46,"value":526},{"type":40,"tag":355,"props":1750,"children":1751},{"class":357,"line":1080},[1752],{"type":40,"tag":355,"props":1753,"children":1754},{"emptyLinePlaceholder":692},[1755],{"type":46,"value":695},{"type":40,"tag":355,"props":1757,"children":1758},{"class":357,"line":1088},[1759],{"type":40,"tag":355,"props":1760,"children":1761},{"style":361},[1762],{"type":46,"value":1763},"    \u002F\u002F Retry only failures, not the whole batch\n",{"type":40,"tag":355,"props":1765,"children":1766},{"class":357,"line":1097},[1767,1771,1776,1780],{"type":40,"tag":355,"props":1768,"children":1769},{"style":371},[1770],{"type":46,"value":870},{"type":40,"tag":355,"props":1772,"children":1773},{"style":407},[1774],{"type":46,"value":1775}," failures",{"type":40,"tag":355,"props":1777,"children":1778},{"style":388},[1779],{"type":46,"value":415},{"type":40,"tag":355,"props":1781,"children":1782},{"style":407},[1783],{"type":46,"value":1784}," results\n",{"type":40,"tag":355,"props":1786,"children":1787},{"class":357,"line":1140},[1788,1793,1797,1801,1805,1810,1814,1819,1823,1827,1832,1836,1841,1846,1850,1855,1859,1864,1868,1873,1878,1883,1887,1892],{"type":40,"tag":355,"props":1789,"children":1790},{"style":388},[1791],{"type":46,"value":1792},"      .",{"type":40,"tag":355,"props":1794,"children":1795},{"style":382},[1796],{"type":46,"value":1706},{"type":40,"tag":355,"props":1798,"children":1799},{"style":543},[1800],{"type":46,"value":546},{"type":40,"tag":355,"props":1802,"children":1803},{"style":388},[1804],{"type":46,"value":546},{"type":40,"tag":355,"props":1806,"children":1807},{"style":822},[1808],{"type":46,"value":1809},"r",{"type":40,"tag":355,"props":1811,"children":1812},{"style":388},[1813],{"type":46,"value":571},{"type":40,"tag":355,"props":1815,"children":1816},{"style":822},[1817],{"type":46,"value":1818}," i",{"type":40,"tag":355,"props":1820,"children":1821},{"style":388},[1822],{"type":46,"value":594},{"type":40,"tag":355,"props":1824,"children":1825},{"style":371},[1826],{"type":46,"value":858},{"type":40,"tag":355,"props":1828,"children":1829},{"style":407},[1830],{"type":46,"value":1831}," r",{"type":40,"tag":355,"props":1833,"children":1834},{"style":388},[1835],{"type":46,"value":431},{"type":40,"tag":355,"props":1837,"children":1838},{"style":407},[1839],{"type":46,"value":1840},"status",{"type":40,"tag":355,"props":1842,"children":1843},{"style":388},[1844],{"type":46,"value":1845}," ===",{"type":40,"tag":355,"props":1847,"children":1848},{"style":388},[1849],{"type":46,"value":672},{"type":40,"tag":355,"props":1851,"children":1852},{"style":448},[1853],{"type":46,"value":1854},"rejected",{"type":40,"tag":355,"props":1856,"children":1857},{"style":388},[1858],{"type":46,"value":682},{"type":40,"tag":355,"props":1860,"children":1861},{"style":388},[1862],{"type":46,"value":1863}," ?",{"type":40,"tag":355,"props":1865,"children":1866},{"style":407},[1867],{"type":46,"value":1523},{"type":40,"tag":355,"props":1869,"children":1870},{"style":543},[1871],{"type":46,"value":1872},"[",{"type":40,"tag":355,"props":1874,"children":1875},{"style":407},[1876],{"type":46,"value":1877},"i",{"type":40,"tag":355,"props":1879,"children":1880},{"style":543},[1881],{"type":46,"value":1882},"] ",{"type":40,"tag":355,"props":1884,"children":1885},{"style":388},[1886],{"type":46,"value":561},{"type":40,"tag":355,"props":1888,"children":1889},{"style":388},[1890],{"type":46,"value":1891}," null",{"type":40,"tag":355,"props":1893,"children":1894},{"style":543},[1895],{"type":46,"value":1896},")\n",{"type":40,"tag":355,"props":1898,"children":1899},{"class":357,"line":1206},[1900,1904,1909,1913,1918,1922],{"type":40,"tag":355,"props":1901,"children":1902},{"style":388},[1903],{"type":46,"value":1792},{"type":40,"tag":355,"props":1905,"children":1906},{"style":382},[1907],{"type":46,"value":1908},"filter",{"type":40,"tag":355,"props":1910,"children":1911},{"style":543},[1912],{"type":46,"value":546},{"type":40,"tag":355,"props":1914,"children":1915},{"style":407},[1916],{"type":46,"value":1917},"Boolean",{"type":40,"tag":355,"props":1919,"children":1920},{"style":543},[1921],{"type":46,"value":594},{"type":40,"tag":355,"props":1923,"children":1924},{"style":388},[1925],{"type":46,"value":526},{"type":40,"tag":355,"props":1927,"children":1928},{"class":357,"line":1269},[1929,1934,1938,1943,1947,1952,1957,1962,1967,1972,1977,1981,1985,1989],{"type":40,"tag":355,"props":1930,"children":1931},{"style":418},[1932],{"type":46,"value":1933},"    if",{"type":40,"tag":355,"props":1935,"children":1936},{"style":543},[1937],{"type":46,"value":819},{"type":40,"tag":355,"props":1939,"children":1940},{"style":407},[1941],{"type":46,"value":1942},"failures",{"type":40,"tag":355,"props":1944,"children":1945},{"style":388},[1946],{"type":46,"value":431},{"type":40,"tag":355,"props":1948,"children":1949},{"style":407},[1950],{"type":46,"value":1951},"length",{"type":40,"tag":355,"props":1953,"children":1954},{"style":388},[1955],{"type":46,"value":1956}," >",{"type":40,"tag":355,"props":1958,"children":1959},{"style":789},[1960],{"type":46,"value":1961}," 0",{"type":40,"tag":355,"props":1963,"children":1964},{"style":543},[1965],{"type":46,"value":1966},") ",{"type":40,"tag":355,"props":1968,"children":1969},{"style":418},[1970],{"type":46,"value":1971},"await",{"type":40,"tag":355,"props":1973,"children":1974},{"style":382},[1975],{"type":46,"value":1976}," enqueueRetry",{"type":40,"tag":355,"props":1978,"children":1979},{"style":543},[1980],{"type":46,"value":546},{"type":40,"tag":355,"props":1982,"children":1983},{"style":407},[1984],{"type":46,"value":1942},{"type":40,"tag":355,"props":1986,"children":1987},{"style":543},[1988],{"type":46,"value":594},{"type":40,"tag":355,"props":1990,"children":1991},{"style":388},[1992],{"type":46,"value":526},{"type":40,"tag":355,"props":1994,"children":1995},{"class":357,"line":1286},[1996],{"type":40,"tag":355,"props":1997,"children":1998},{"style":388},[1999],{"type":46,"value":1061},{"type":40,"tag":355,"props":2001,"children":2003},{"class":357,"line":2002},22,[2004,2008,2012],{"type":40,"tag":355,"props":2005,"children":2006},{"style":388},[2007],{"type":46,"value":484},{"type":40,"tag":355,"props":2009,"children":2010},{"style":407},[2011],{"type":46,"value":594},{"type":40,"tag":355,"props":2013,"children":2014},{"style":388},[2015],{"type":46,"value":526},{"type":40,"tag":61,"props":2017,"children":2019},{"id":2018},"anti-patterns",[2020],{"type":46,"value":2021},"Anti-Patterns",{"type":40,"tag":344,"props":2023,"children":2025},{"className":346,"code":2024,"language":348,"meta":349,"style":349},"\u002F\u002F Dangerous: polling for unprocessed rows on a timer\n\u002F\u002F Race conditions with multiple instances, no failure isolation,\n\u002F\u002F duplicate emails if process crashes between send and flag update\nconst job = cron(\"*\u002F5 * * * *\", async () => {\n  const users = await db.user.findMany({ where: { welcomeEmailSent: false } });\n  for (const user of users) {\n    await sendWelcomeEmail(user);\n    await db.user.update({ where: { id: user.id }, data: { welcomeEmailSent: true } });\n  }\n});\n\n\u002F\u002F Dangerous: shrinking interval as scaling strategy\n\u002F\u002F Started at 5min, now 10sec. What if processing takes 15sec? Overlap.\nsetInterval(async () => {\n  const events = await db.event.findMany({\n    where: { processedAt: null }, take: 1000,\n  });\n  await processEvents(events); \u002F\u002F takes longer than interval under load\n}, 10_000);\n\n\u002F\u002F Dangerous: one bad item kills the whole batch\nconst orders = await db.order.findMany({ where: { date: today } });\nconst report = orders.map(order => ({\n  revenue: calculateRevenue(order),  \u002F\u002F throws on malformed data\n  tax: calculateTax(order),          \u002F\u002F throws on missing region\n}));\n\u002F\u002F Order #5,000 throws. All 50,000 orders lost. Retry all or skip?\n",[2026],{"type":40,"tag":246,"props":2027,"children":2028},{"__ignoreMap":349},[2029,2037,2045,2053,2113,2204,2241,2268,2382,2390,2405,2412,2420,2428,2455,2502,2553,2569,2604,2625,2632,2640,2730,2780,2812,2843,2860],{"type":40,"tag":355,"props":2030,"children":2031},{"class":357,"line":27},[2032],{"type":40,"tag":355,"props":2033,"children":2034},{"style":361},[2035],{"type":46,"value":2036},"\u002F\u002F Dangerous: polling for unprocessed rows on a timer\n",{"type":40,"tag":355,"props":2038,"children":2039},{"class":357,"line":367},[2040],{"type":40,"tag":355,"props":2041,"children":2042},{"style":361},[2043],{"type":46,"value":2044},"\u002F\u002F Race conditions with multiple instances, no failure isolation,\n",{"type":40,"tag":355,"props":2046,"children":2047},{"class":357,"line":23},[2048],{"type":40,"tag":355,"props":2049,"children":2050},{"style":361},[2051],{"type":46,"value":2052},"\u002F\u002F duplicate emails if process crashes between send and flag update\n",{"type":40,"tag":355,"props":2054,"children":2055},{"class":357,"line":444},[2056,2061,2066,2070,2075,2079,2083,2088,2092,2096,2100,2105,2109],{"type":40,"tag":355,"props":2057,"children":2058},{"style":371},[2059],{"type":46,"value":2060},"const",{"type":40,"tag":355,"props":2062,"children":2063},{"style":407},[2064],{"type":46,"value":2065}," job ",{"type":40,"tag":355,"props":2067,"children":2068},{"style":388},[2069],{"type":46,"value":718},{"type":40,"tag":355,"props":2071,"children":2072},{"style":382},[2073],{"type":46,"value":2074}," cron",{"type":40,"tag":355,"props":2076,"children":2077},{"style":407},[2078],{"type":46,"value":546},{"type":40,"tag":355,"props":2080,"children":2081},{"style":388},[2082],{"type":46,"value":682},{"type":40,"tag":355,"props":2084,"children":2085},{"style":448},[2086],{"type":46,"value":2087},"*\u002F5 * * * *",{"type":40,"tag":355,"props":2089,"children":2090},{"style":388},[2091],{"type":46,"value":682},{"type":40,"tag":355,"props":2093,"children":2094},{"style":388},[2095],{"type":46,"value":571},{"type":40,"tag":355,"props":2097,"children":2098},{"style":371},[2099],{"type":46,"value":814},{"type":40,"tag":355,"props":2101,"children":2102},{"style":388},[2103],{"type":46,"value":2104}," ()",{"type":40,"tag":355,"props":2106,"children":2107},{"style":371},[2108],{"type":46,"value":858},{"type":40,"tag":355,"props":2110,"children":2111},{"style":388},[2112],{"type":46,"value":396},{"type":40,"tag":355,"props":2114,"children":2115},{"class":357,"line":454},[2116,2120,2125,2129,2133,2137,2141,2145,2149,2153,2157,2161,2165,2169,2173,2178,2182,2188,2192,2196,2200],{"type":40,"tag":355,"props":2117,"children":2118},{"style":371},[2119],{"type":46,"value":404},{"type":40,"tag":355,"props":2121,"children":2122},{"style":407},[2123],{"type":46,"value":2124}," users",{"type":40,"tag":355,"props":2126,"children":2127},{"style":388},[2128],{"type":46,"value":415},{"type":40,"tag":355,"props":2130,"children":2131},{"style":418},[2132],{"type":46,"value":421},{"type":40,"tag":355,"props":2134,"children":2135},{"style":407},[2136],{"type":46,"value":426},{"type":40,"tag":355,"props":2138,"children":2139},{"style":388},[2140],{"type":46,"value":431},{"type":40,"tag":355,"props":2142,"children":2143},{"style":407},[2144],{"type":46,"value":896},{"type":40,"tag":355,"props":2146,"children":2147},{"style":388},[2148],{"type":46,"value":431},{"type":40,"tag":355,"props":2150,"children":2151},{"style":382},[2152],{"type":46,"value":1553},{"type":40,"tag":355,"props":2154,"children":2155},{"style":543},[2156],{"type":46,"value":546},{"type":40,"tag":355,"props":2158,"children":2159},{"style":388},[2160],{"type":46,"value":551},{"type":40,"tag":355,"props":2162,"children":2163},{"style":543},[2164],{"type":46,"value":918},{"type":40,"tag":355,"props":2166,"children":2167},{"style":388},[2168],{"type":46,"value":561},{"type":40,"tag":355,"props":2170,"children":2171},{"style":388},[2172],{"type":46,"value":653},{"type":40,"tag":355,"props":2174,"children":2175},{"style":543},[2176],{"type":46,"value":2177}," welcomeEmailSent",{"type":40,"tag":355,"props":2179,"children":2180},{"style":388},[2181],{"type":46,"value":561},{"type":40,"tag":355,"props":2183,"children":2185},{"style":2184},"--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC",[2186],{"type":46,"value":2187}," false",{"type":40,"tag":355,"props":2189,"children":2190},{"style":388},[2191],{"type":46,"value":589},{"type":40,"tag":355,"props":2193,"children":2194},{"style":388},[2195],{"type":46,"value":589},{"type":40,"tag":355,"props":2197,"children":2198},{"style":543},[2199],{"type":46,"value":594},{"type":40,"tag":355,"props":2201,"children":2202},{"style":388},[2203],{"type":46,"value":526},{"type":40,"tag":355,"props":2205,"children":2206},{"class":357,"line":463},[2207,2212,2216,2220,2224,2229,2233,2237],{"type":40,"tag":355,"props":2208,"children":2209},{"style":418},[2210],{"type":46,"value":2211},"  for",{"type":40,"tag":355,"props":2213,"children":2214},{"style":543},[2215],{"type":46,"value":819},{"type":40,"tag":355,"props":2217,"children":2218},{"style":371},[2219],{"type":46,"value":2060},{"type":40,"tag":355,"props":2221,"children":2222},{"style":407},[2223],{"type":46,"value":875},{"type":40,"tag":355,"props":2225,"children":2226},{"style":388},[2227],{"type":46,"value":2228}," of",{"type":40,"tag":355,"props":2230,"children":2231},{"style":407},[2232],{"type":46,"value":2124},{"type":40,"tag":355,"props":2234,"children":2235},{"style":543},[2236],{"type":46,"value":1966},{"type":40,"tag":355,"props":2238,"children":2239},{"style":388},[2240],{"type":46,"value":731},{"type":40,"tag":355,"props":2242,"children":2243},{"class":357,"line":506},[2244,2248,2252,2256,2260,2264],{"type":40,"tag":355,"props":2245,"children":2246},{"style":418},[2247],{"type":46,"value":973},{"type":40,"tag":355,"props":2249,"children":2250},{"style":382},[2251],{"type":46,"value":978},{"type":40,"tag":355,"props":2253,"children":2254},{"style":543},[2255],{"type":46,"value":546},{"type":40,"tag":355,"props":2257,"children":2258},{"style":407},[2259],{"type":46,"value":896},{"type":40,"tag":355,"props":2261,"children":2262},{"style":543},[2263],{"type":46,"value":594},{"type":40,"tag":355,"props":2265,"children":2266},{"style":388},[2267],{"type":46,"value":526},{"type":40,"tag":355,"props":2269,"children":2270},{"class":357,"line":515},[2271,2275,2279,2283,2287,2291,2296,2300,2304,2308,2312,2316,2320,2324,2328,2332,2336,2341,2345,2349,2353,2357,2361,2366,2370,2374,2378],{"type":40,"tag":355,"props":2272,"children":2273},{"style":418},[2274],{"type":46,"value":973},{"type":40,"tag":355,"props":2276,"children":2277},{"style":407},[2278],{"type":46,"value":426},{"type":40,"tag":355,"props":2280,"children":2281},{"style":388},[2282],{"type":46,"value":431},{"type":40,"tag":355,"props":2284,"children":2285},{"style":407},[2286],{"type":46,"value":896},{"type":40,"tag":355,"props":2288,"children":2289},{"style":388},[2290],{"type":46,"value":431},{"type":40,"tag":355,"props":2292,"children":2293},{"style":382},[2294],{"type":46,"value":2295},"update",{"type":40,"tag":355,"props":2297,"children":2298},{"style":543},[2299],{"type":46,"value":546},{"type":40,"tag":355,"props":2301,"children":2302},{"style":388},[2303],{"type":46,"value":551},{"type":40,"tag":355,"props":2305,"children":2306},{"style":543},[2307],{"type":46,"value":918},{"type":40,"tag":355,"props":2309,"children":2310},{"style":388},[2311],{"type":46,"value":561},{"type":40,"tag":355,"props":2313,"children":2314},{"style":388},[2315],{"type":46,"value":653},{"type":40,"tag":355,"props":2317,"children":2318},{"style":543},[2319],{"type":46,"value":931},{"type":40,"tag":355,"props":2321,"children":2322},{"style":388},[2323],{"type":46,"value":561},{"type":40,"tag":355,"props":2325,"children":2326},{"style":407},[2327],{"type":46,"value":875},{"type":40,"tag":355,"props":2329,"children":2330},{"style":388},[2331],{"type":46,"value":431},{"type":40,"tag":355,"props":2333,"children":2334},{"style":407},[2335],{"type":46,"value":1254},{"type":40,"tag":355,"props":2337,"children":2338},{"style":388},[2339],{"type":46,"value":2340}," },",{"type":40,"tag":355,"props":2342,"children":2343},{"style":543},[2344],{"type":46,"value":1191},{"type":40,"tag":355,"props":2346,"children":2347},{"style":388},[2348],{"type":46,"value":561},{"type":40,"tag":355,"props":2350,"children":2351},{"style":388},[2352],{"type":46,"value":653},{"type":40,"tag":355,"props":2354,"children":2355},{"style":543},[2356],{"type":46,"value":2177},{"type":40,"tag":355,"props":2358,"children":2359},{"style":388},[2360],{"type":46,"value":561},{"type":40,"tag":355,"props":2362,"children":2363},{"style":2184},[2364],{"type":46,"value":2365}," true",{"type":40,"tag":355,"props":2367,"children":2368},{"style":388},[2369],{"type":46,"value":589},{"type":40,"tag":355,"props":2371,"children":2372},{"style":388},[2373],{"type":46,"value":589},{"type":40,"tag":355,"props":2375,"children":2376},{"style":543},[2377],{"type":46,"value":594},{"type":40,"tag":355,"props":2379,"children":2380},{"style":388},[2381],{"type":46,"value":526},{"type":40,"tag":355,"props":2383,"children":2384},{"class":357,"line":529},[2385],{"type":40,"tag":355,"props":2386,"children":2387},{"style":388},[2388],{"type":46,"value":2389},"  }\n",{"type":40,"tag":355,"props":2391,"children":2392},{"class":357,"line":601},[2393,2397,2401],{"type":40,"tag":355,"props":2394,"children":2395},{"style":388},[2396],{"type":46,"value":484},{"type":40,"tag":355,"props":2398,"children":2399},{"style":407},[2400],{"type":46,"value":594},{"type":40,"tag":355,"props":2402,"children":2403},{"style":388},[2404],{"type":46,"value":526},{"type":40,"tag":355,"props":2406,"children":2407},{"class":357,"line":997},[2408],{"type":40,"tag":355,"props":2409,"children":2410},{"emptyLinePlaceholder":692},[2411],{"type":46,"value":695},{"type":40,"tag":355,"props":2413,"children":2414},{"class":357,"line":1026},[2415],{"type":40,"tag":355,"props":2416,"children":2417},{"style":361},[2418],{"type":46,"value":2419},"\u002F\u002F Dangerous: shrinking interval as scaling strategy\n",{"type":40,"tag":355,"props":2421,"children":2422},{"class":357,"line":1055},[2423],{"type":40,"tag":355,"props":2424,"children":2425},{"style":361},[2426],{"type":46,"value":2427},"\u002F\u002F Started at 5min, now 10sec. What if processing takes 15sec? Overlap.\n",{"type":40,"tag":355,"props":2429,"children":2430},{"class":357,"line":1064},[2431,2435,2439,2443,2447,2451],{"type":40,"tag":355,"props":2432,"children":2433},{"style":382},[2434],{"type":46,"value":265},{"type":40,"tag":355,"props":2436,"children":2437},{"style":407},[2438],{"type":46,"value":546},{"type":40,"tag":355,"props":2440,"children":2441},{"style":371},[2442],{"type":46,"value":374},{"type":40,"tag":355,"props":2444,"children":2445},{"style":388},[2446],{"type":46,"value":2104},{"type":40,"tag":355,"props":2448,"children":2449},{"style":371},[2450],{"type":46,"value":858},{"type":40,"tag":355,"props":2452,"children":2453},{"style":388},[2454],{"type":46,"value":396},{"type":40,"tag":355,"props":2456,"children":2457},{"class":357,"line":1080},[2458,2462,2466,2470,2474,2478,2482,2486,2490,2494,2498],{"type":40,"tag":355,"props":2459,"children":2460},{"style":371},[2461],{"type":46,"value":404},{"type":40,"tag":355,"props":2463,"children":2464},{"style":407},[2465],{"type":46,"value":1523},{"type":40,"tag":355,"props":2467,"children":2468},{"style":388},[2469],{"type":46,"value":415},{"type":40,"tag":355,"props":2471,"children":2472},{"style":418},[2473],{"type":46,"value":421},{"type":40,"tag":355,"props":2475,"children":2476},{"style":407},[2477],{"type":46,"value":426},{"type":40,"tag":355,"props":2479,"children":2480},{"style":388},[2481],{"type":46,"value":431},{"type":40,"tag":355,"props":2483,"children":2484},{"style":407},[2485],{"type":46,"value":1544},{"type":40,"tag":355,"props":2487,"children":2488},{"style":388},[2489],{"type":46,"value":431},{"type":40,"tag":355,"props":2491,"children":2492},{"style":382},[2493],{"type":46,"value":1553},{"type":40,"tag":355,"props":2495,"children":2496},{"style":543},[2497],{"type":46,"value":546},{"type":40,"tag":355,"props":2499,"children":2500},{"style":388},[2501],{"type":46,"value":731},{"type":40,"tag":355,"props":2503,"children":2504},{"class":357,"line":1088},[2505,2510,2514,2518,2523,2527,2531,2535,2540,2544,2549],{"type":40,"tag":355,"props":2506,"children":2507},{"style":543},[2508],{"type":46,"value":2509},"    where",{"type":40,"tag":355,"props":2511,"children":2512},{"style":388},[2513],{"type":46,"value":561},{"type":40,"tag":355,"props":2515,"children":2516},{"style":388},[2517],{"type":46,"value":653},{"type":40,"tag":355,"props":2519,"children":2520},{"style":543},[2521],{"type":46,"value":2522}," processedAt",{"type":40,"tag":355,"props":2524,"children":2525},{"style":388},[2526],{"type":46,"value":561},{"type":40,"tag":355,"props":2528,"children":2529},{"style":388},[2530],{"type":46,"value":1891},{"type":40,"tag":355,"props":2532,"children":2533},{"style":388},[2534],{"type":46,"value":2340},{"type":40,"tag":355,"props":2536,"children":2537},{"style":543},[2538],{"type":46,"value":2539}," take",{"type":40,"tag":355,"props":2541,"children":2542},{"style":388},[2543],{"type":46,"value":561},{"type":40,"tag":355,"props":2545,"children":2546},{"style":789},[2547],{"type":46,"value":2548}," 1000",{"type":40,"tag":355,"props":2550,"children":2551},{"style":388},[2552],{"type":46,"value":761},{"type":40,"tag":355,"props":2554,"children":2555},{"class":357,"line":1097},[2556,2561,2565],{"type":40,"tag":355,"props":2557,"children":2558},{"style":388},[2559],{"type":46,"value":2560},"  }",{"type":40,"tag":355,"props":2562,"children":2563},{"style":543},[2564],{"type":46,"value":594},{"type":40,"tag":355,"props":2566,"children":2567},{"style":388},[2568],{"type":46,"value":526},{"type":40,"tag":355,"props":2570,"children":2571},{"class":357,"line":1140},[2572,2576,2581,2585,2590,2594,2599],{"type":40,"tag":355,"props":2573,"children":2574},{"style":418},[2575],{"type":46,"value":535},{"type":40,"tag":355,"props":2577,"children":2578},{"style":382},[2579],{"type":46,"value":2580}," processEvents",{"type":40,"tag":355,"props":2582,"children":2583},{"style":543},[2584],{"type":46,"value":546},{"type":40,"tag":355,"props":2586,"children":2587},{"style":407},[2588],{"type":46,"value":2589},"events",{"type":40,"tag":355,"props":2591,"children":2592},{"style":543},[2593],{"type":46,"value":594},{"type":40,"tag":355,"props":2595,"children":2596},{"style":388},[2597],{"type":46,"value":2598},";",{"type":40,"tag":355,"props":2600,"children":2601},{"style":361},[2602],{"type":46,"value":2603}," \u002F\u002F takes longer than interval under load\n",{"type":40,"tag":355,"props":2605,"children":2606},{"class":357,"line":1206},[2607,2612,2617,2621],{"type":40,"tag":355,"props":2608,"children":2609},{"style":388},[2610],{"type":46,"value":2611},"},",{"type":40,"tag":355,"props":2613,"children":2614},{"style":789},[2615],{"type":46,"value":2616}," 10_000",{"type":40,"tag":355,"props":2618,"children":2619},{"style":407},[2620],{"type":46,"value":594},{"type":40,"tag":355,"props":2622,"children":2623},{"style":388},[2624],{"type":46,"value":526},{"type":40,"tag":355,"props":2626,"children":2627},{"class":357,"line":1269},[2628],{"type":40,"tag":355,"props":2629,"children":2630},{"emptyLinePlaceholder":692},[2631],{"type":46,"value":695},{"type":40,"tag":355,"props":2633,"children":2634},{"class":357,"line":1286},[2635],{"type":40,"tag":355,"props":2636,"children":2637},{"style":361},[2638],{"type":46,"value":2639},"\u002F\u002F Dangerous: one bad item kills the whole batch\n",{"type":40,"tag":355,"props":2641,"children":2642},{"class":357,"line":2002},[2643,2647,2652,2656,2660,2664,2668,2673,2677,2681,2685,2689,2693,2697,2701,2705,2709,2714,2718,2722,2726],{"type":40,"tag":355,"props":2644,"children":2645},{"style":371},[2646],{"type":46,"value":2060},{"type":40,"tag":355,"props":2648,"children":2649},{"style":407},[2650],{"type":46,"value":2651}," orders ",{"type":40,"tag":355,"props":2653,"children":2654},{"style":388},[2655],{"type":46,"value":718},{"type":40,"tag":355,"props":2657,"children":2658},{"style":418},[2659],{"type":46,"value":421},{"type":40,"tag":355,"props":2661,"children":2662},{"style":407},[2663],{"type":46,"value":426},{"type":40,"tag":355,"props":2665,"children":2666},{"style":388},[2667],{"type":46,"value":431},{"type":40,"tag":355,"props":2669,"children":2670},{"style":407},[2671],{"type":46,"value":2672},"order",{"type":40,"tag":355,"props":2674,"children":2675},{"style":388},[2676],{"type":46,"value":431},{"type":40,"tag":355,"props":2678,"children":2679},{"style":382},[2680],{"type":46,"value":1553},{"type":40,"tag":355,"props":2682,"children":2683},{"style":407},[2684],{"type":46,"value":546},{"type":40,"tag":355,"props":2686,"children":2687},{"style":388},[2688],{"type":46,"value":551},{"type":40,"tag":355,"props":2690,"children":2691},{"style":543},[2692],{"type":46,"value":918},{"type":40,"tag":355,"props":2694,"children":2695},{"style":388},[2696],{"type":46,"value":561},{"type":40,"tag":355,"props":2698,"children":2699},{"style":388},[2700],{"type":46,"value":653},{"type":40,"tag":355,"props":2702,"children":2703},{"style":543},[2704],{"type":46,"value":556},{"type":40,"tag":355,"props":2706,"children":2707},{"style":388},[2708],{"type":46,"value":561},{"type":40,"tag":355,"props":2710,"children":2711},{"style":407},[2712],{"type":46,"value":2713}," today ",{"type":40,"tag":355,"props":2715,"children":2716},{"style":388},[2717],{"type":46,"value":484},{"type":40,"tag":355,"props":2719,"children":2720},{"style":388},[2721],{"type":46,"value":589},{"type":40,"tag":355,"props":2723,"children":2724},{"style":407},[2725],{"type":46,"value":594},{"type":40,"tag":355,"props":2727,"children":2728},{"style":388},[2729],{"type":46,"value":526},{"type":40,"tag":355,"props":2731,"children":2733},{"class":357,"line":2732},23,[2734,2738,2743,2747,2752,2756,2760,2764,2768,2772,2776],{"type":40,"tag":355,"props":2735,"children":2736},{"style":371},[2737],{"type":46,"value":2060},{"type":40,"tag":355,"props":2739,"children":2740},{"style":407},[2741],{"type":46,"value":2742}," report ",{"type":40,"tag":355,"props":2744,"children":2745},{"style":388},[2746],{"type":46,"value":718},{"type":40,"tag":355,"props":2748,"children":2749},{"style":407},[2750],{"type":46,"value":2751}," orders",{"type":40,"tag":355,"props":2753,"children":2754},{"style":388},[2755],{"type":46,"value":431},{"type":40,"tag":355,"props":2757,"children":2758},{"style":382},[2759],{"type":46,"value":1706},{"type":40,"tag":355,"props":2761,"children":2762},{"style":407},[2763],{"type":46,"value":546},{"type":40,"tag":355,"props":2765,"children":2766},{"style":822},[2767],{"type":46,"value":2672},{"type":40,"tag":355,"props":2769,"children":2770},{"style":371},[2771],{"type":46,"value":858},{"type":40,"tag":355,"props":2773,"children":2774},{"style":407},[2775],{"type":46,"value":819},{"type":40,"tag":355,"props":2777,"children":2778},{"style":388},[2779],{"type":46,"value":731},{"type":40,"tag":355,"props":2781,"children":2783},{"class":357,"line":2782},24,[2784,2789,2793,2798,2803,2807],{"type":40,"tag":355,"props":2785,"children":2786},{"style":543},[2787],{"type":46,"value":2788},"  revenue",{"type":40,"tag":355,"props":2790,"children":2791},{"style":388},[2792],{"type":46,"value":561},{"type":40,"tag":355,"props":2794,"children":2795},{"style":382},[2796],{"type":46,"value":2797}," calculateRevenue",{"type":40,"tag":355,"props":2799,"children":2800},{"style":407},[2801],{"type":46,"value":2802},"(order)",{"type":40,"tag":355,"props":2804,"children":2805},{"style":388},[2806],{"type":46,"value":571},{"type":40,"tag":355,"props":2808,"children":2809},{"style":361},[2810],{"type":46,"value":2811},"  \u002F\u002F throws on malformed data\n",{"type":40,"tag":355,"props":2813,"children":2815},{"class":357,"line":2814},25,[2816,2821,2825,2830,2834,2838],{"type":40,"tag":355,"props":2817,"children":2818},{"style":543},[2819],{"type":46,"value":2820},"  tax",{"type":40,"tag":355,"props":2822,"children":2823},{"style":388},[2824],{"type":46,"value":561},{"type":40,"tag":355,"props":2826,"children":2827},{"style":382},[2828],{"type":46,"value":2829}," calculateTax",{"type":40,"tag":355,"props":2831,"children":2832},{"style":407},[2833],{"type":46,"value":2802},{"type":40,"tag":355,"props":2835,"children":2836},{"style":388},[2837],{"type":46,"value":571},{"type":40,"tag":355,"props":2839,"children":2840},{"style":361},[2841],{"type":46,"value":2842},"          \u002F\u002F throws on missing region\n",{"type":40,"tag":355,"props":2844,"children":2846},{"class":357,"line":2845},26,[2847,2851,2856],{"type":40,"tag":355,"props":2848,"children":2849},{"style":388},[2850],{"type":46,"value":484},{"type":40,"tag":355,"props":2852,"children":2853},{"style":407},[2854],{"type":46,"value":2855},"))",{"type":40,"tag":355,"props":2857,"children":2858},{"style":388},[2859],{"type":46,"value":526},{"type":40,"tag":355,"props":2861,"children":2863},{"class":357,"line":2862},27,[2864],{"type":40,"tag":355,"props":2865,"children":2866},{"style":361},[2867],{"type":46,"value":2868},"\u002F\u002F Order #5,000 throws. All 50,000 orders lost. Retry all or skip?\n",{"type":40,"tag":61,"props":2870,"children":2872},{"id":2871},"related-traps",[2873],{"type":46,"value":2874},"Related Traps",{"type":40,"tag":320,"props":2876,"children":2877},{},[2878,2888,2898,2908],{"type":40,"tag":235,"props":2879,"children":2880},{},[2881,2886],{"type":40,"tag":55,"props":2882,"children":2883},{},[2884],{"type":46,"value":2885},"Cardinality",{"type":46,"value":2887}," -- high-cardinality data growing over time is the forcing function that breaks batch. When batch size grows because data volume grows, you need streaming, not a shorter interval.",{"type":40,"tag":235,"props":2889,"children":2890},{},[2891,2896],{"type":40,"tag":55,"props":2892,"children":2893},{},[2894],{"type":46,"value":2895},"Backpressure",{"type":46,"value":2897}," -- stream processors handle backpressure naturally (consumer pulls at its own pace). Batch processors don't -- if the batch is bigger than the system can handle, it fails.",{"type":40,"tag":235,"props":2899,"children":2900},{},[2901,2906],{"type":40,"tag":55,"props":2902,"children":2903},{},[2904],{"type":46,"value":2905},"Idempotency",{"type":46,"value":2907}," -- stream\u002Fevent processing requires idempotent handlers because messages can be delivered more than once. Batch systems often skip this and break when they retry.",{"type":40,"tag":235,"props":2909,"children":2910},{},[2911,2916,2918,2924],{"type":40,"tag":55,"props":2912,"children":2913},{},[2914],{"type":46,"value":2915},"Race Conditions",{"type":46,"value":2917}," -- polling-based batch processing is inherently racy. Two instances polling for ",{"type":40,"tag":246,"props":2919,"children":2921},{"className":2920},[],[2922],{"type":46,"value":2923},"WHERE processed = false",{"type":46,"value":2925}," at the same time pick up the same rows.",{"type":40,"tag":2927,"props":2928,"children":2929},"style",{},[2930],{"type":46,"value":2931},"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":2933,"total":2845},[2934,2953,2966,2976,2993,3008,3022,3039,3052,3064,3075,3086],{"slug":2935,"name":2935,"fn":2936,"description":2937,"org":2938,"tags":2939,"stars":2950,"repoUrl":2951,"updatedAt":2952},"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},[2940,2943,2946,2947],{"name":2941,"slug":2942,"type":16},"Agents","agents",{"name":2944,"slug":2945,"type":16},"SDK","sdk",{"name":9,"slug":8,"type":16},{"name":2948,"slug":2949,"type":16},"Workflow Automation","workflow-automation",14401,"https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Ftrigger.dev","2026-07-02T17:12:52.307135",{"slug":2954,"name":2954,"fn":2955,"description":2956,"org":2957,"tags":2958,"stars":2950,"repoUrl":2951,"updatedAt":2965},"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},[2959,2962,2963,2964],{"name":2960,"slug":2961,"type":16},"Backend","backend",{"name":2944,"slug":2945,"type":16},{"name":9,"slug":8,"type":16},{"name":2948,"slug":2949,"type":16},"2026-07-02T17:12:48.396964",{"slug":2967,"name":2967,"fn":2968,"description":2969,"org":2970,"tags":2971,"stars":2950,"repoUrl":2951,"updatedAt":2975},"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},[2972,2973,2974],{"name":2941,"slug":2942,"type":16},{"name":9,"slug":8,"type":16},{"name":2948,"slug":2949,"type":16},"2026-07-02T17:12:51.03018",{"slug":2977,"name":2977,"fn":2978,"description":2979,"org":2980,"tags":2981,"stars":2950,"repoUrl":2951,"updatedAt":2992},"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},[2982,2985,2988,2991],{"name":2983,"slug":2984,"type":16},"Frontend","frontend",{"name":2986,"slug":2987,"type":16},"React","react",{"name":2989,"slug":2990,"type":16},"Real-time","real-time",{"name":9,"slug":8,"type":16},"2026-07-02T17:12:49.717706",{"slug":2994,"name":2994,"fn":2995,"description":2996,"org":2997,"tags":2998,"stars":3005,"repoUrl":3006,"updatedAt":3007},"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},[2999,3000,3003,3004],{"name":2941,"slug":2942,"type":16},{"name":3001,"slug":3002,"type":16},"Multi-Agent","multi-agent",{"name":9,"slug":8,"type":16},{"name":2948,"slug":2949,"type":16},30,"https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Fskills","2026-04-06T18:54:46.023553",{"slug":3009,"name":3009,"fn":3010,"description":3011,"org":3012,"tags":3013,"stars":3005,"repoUrl":3006,"updatedAt":3021},"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},[3014,3017,3020],{"name":3015,"slug":3016,"type":16},"Configuration","configuration",{"name":3018,"slug":3019,"type":16},"Deployment","deployment",{"name":9,"slug":8,"type":16},"2026-04-06T18:54:44.764258",{"slug":3023,"name":3023,"fn":3024,"description":3025,"org":3026,"tags":3027,"stars":3005,"repoUrl":3006,"updatedAt":3038},"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},[3028,3031,3034,3037],{"name":3029,"slug":3030,"type":16},"Analytics","analytics",{"name":3032,"slug":3033,"type":16},"Cost Optimization","cost-optimization",{"name":3035,"slug":3036,"type":16},"Operations","operations",{"name":9,"slug":8,"type":16},"2026-04-06T18:54:48.555552",{"slug":3040,"name":3040,"fn":3041,"description":3042,"org":3043,"tags":3044,"stars":3005,"repoUrl":3006,"updatedAt":3051},"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},[3045,3046,3049,3050],{"name":2983,"slug":2984,"type":16},{"name":3047,"slug":3048,"type":16},"Observability","observability",{"name":2989,"slug":2990,"type":16},{"name":9,"slug":8,"type":16},"2026-04-06T18:54:47.293822",{"slug":3053,"name":3053,"fn":3054,"description":3055,"org":3056,"tags":3057,"stars":3005,"repoUrl":3006,"updatedAt":3063},"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},[3058,3059,3062],{"name":3015,"slug":3016,"type":16},{"name":3060,"slug":3061,"type":16},"Local Development","local-development",{"name":9,"slug":8,"type":16},"2026-04-06T18:54:42.280816",{"slug":3065,"name":3065,"fn":3066,"description":3067,"org":3068,"tags":3069,"stars":3005,"repoUrl":3006,"updatedAt":3074},"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},[3070,3071,3072,3073],{"name":2941,"slug":2942,"type":16},{"name":2960,"slug":2961,"type":16},{"name":9,"slug":8,"type":16},{"name":2948,"slug":2949,"type":16},"2026-04-06T18:54:43.514369",{"slug":3076,"name":3076,"fn":3077,"description":3078,"org":3079,"tags":3080,"stars":23,"repoUrl":24,"updatedAt":3085},"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},[3081,3082],{"name":14,"slug":15,"type":16},{"name":3083,"slug":3084,"type":16},"Performance","performance","2026-06-17T08:40:42.723559",{"slug":3087,"name":3087,"fn":3088,"description":3089,"org":3090,"tags":3091,"stars":23,"repoUrl":24,"updatedAt":3100},"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},[3092,3093,3096,3099],{"name":14,"slug":15,"type":16},{"name":3094,"slug":3095,"type":16},"Caching","caching",{"name":3097,"slug":3098,"type":16},"Engineering","engineering",{"name":3083,"slug":3084,"type":16},"2026-06-17T08:40:45.194583",{"items":3102,"total":1088},[3103,3108,3115,3125,3137,3150,3162],{"slug":3076,"name":3076,"fn":3077,"description":3078,"org":3104,"tags":3105,"stars":23,"repoUrl":24,"updatedAt":3085},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3106,3107],{"name":14,"slug":15,"type":16},{"name":3083,"slug":3084,"type":16},{"slug":3087,"name":3087,"fn":3088,"description":3089,"org":3109,"tags":3110,"stars":23,"repoUrl":24,"updatedAt":3100},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3111,3112,3113,3114],{"name":14,"slug":15,"type":16},{"name":3094,"slug":3095,"type":16},{"name":3097,"slug":3098,"type":16},{"name":3083,"slug":3084,"type":16},{"slug":3116,"name":3116,"fn":3117,"description":3118,"org":3119,"tags":3120,"stars":23,"repoUrl":24,"updatedAt":3124},"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},[3121,3122,3123],{"name":14,"slug":15,"type":16},{"name":3097,"slug":3098,"type":16},{"name":3083,"slug":3084,"type":16},"2026-06-17T08:40:40.264608",{"slug":3126,"name":3126,"fn":3127,"description":3128,"org":3129,"tags":3130,"stars":23,"repoUrl":24,"updatedAt":3136},"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},[3131,3132,3135],{"name":14,"slug":15,"type":16},{"name":3133,"slug":3134,"type":16},"Debugging","debugging",{"name":3097,"slug":3098,"type":16},"2026-06-17T08:40:37.803541",{"slug":3138,"name":3138,"fn":3139,"description":3140,"org":3141,"tags":3142,"stars":23,"repoUrl":24,"updatedAt":3149},"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},[3143,3144,3147,3148],{"name":14,"slug":15,"type":16},{"name":3145,"slug":3146,"type":16},"Database","database",{"name":3097,"slug":3098,"type":16},{"name":3083,"slug":3084,"type":16},"2026-06-17T08:40:46.442182",{"slug":3151,"name":3151,"fn":3152,"description":3153,"org":3154,"tags":3155,"stars":23,"repoUrl":24,"updatedAt":3161},"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},[3156,3157,3160],{"name":14,"slug":15,"type":16},{"name":3158,"slug":3159,"type":16},"Data Modeling","data-modeling",{"name":3145,"slug":3146,"type":16},"2026-06-17T08:40:53.835868",{"slug":3163,"name":3163,"fn":3164,"description":3165,"org":3166,"tags":3167,"stars":23,"repoUrl":24,"updatedAt":3173},"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},[3168,3171,3172],{"name":3169,"slug":3170,"type":16},"API Development","api-development",{"name":14,"slug":15,"type":16},{"name":3097,"slug":3098,"type":16},"2026-06-17T08:40:47.666795"]