[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-inngest-inngest-middleware":3,"mdc-ltys0h-key":44,"related-org-inngest-inngest-middleware":3963,"related-repo-inngest-inngest-middleware":4125},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":11,"stars":26,"repoUrl":27,"updatedAt":28,"license":29,"forks":30,"topics":31,"repo":39,"sourceUrl":42,"mdContent":43},"inngest-middleware","add middleware to Inngest durable functions","Use when adding cross-cutting concerns to durable functions — structured logging or tracing across all functions, error tracking with Sentry, payload encryption for sensitive data, dependency injection of clients (DB, Stripe, etc.) into function handlers, custom telemetry, or behavior that should apply uniformly across many functions. Covers Inngest middleware lifecycle, creating custom middleware, dependencyInjectionMiddleware, @inngest\u002Fmiddleware-encryption, @inngest\u002Fmiddleware-sentry, and custom middleware patterns.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},"inngest","Inngest","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Finngest.png",[12,16,17,20,23],{"name":13,"slug":14,"type":15},"Observability","observability","tag",{"name":9,"slug":8,"type":15},{"name":18,"slug":19,"type":15},"Engineering","engineering",{"name":21,"slug":22,"type":15},"Middleware","middleware",{"name":24,"slug":25,"type":15},"Sentry","sentry",26,"https:\u002F\u002Fgithub.com\u002Finngest\u002Finngest-skills","2026-07-12T07:36:50.127999",null,5,[32,33,34,35,36,37,38],"agent-skill-repository","agent-skills","agentic-skills","ai-agents","claude-code-skills","cursor-skills","openclaw-skills",{"repoUrl":27,"stars":26,"forks":30,"topics":40,"description":41},[32,33,34,35,36,37,38],"Agent Skills for building with Inngest","https:\u002F\u002Fgithub.com\u002Finngest\u002Finngest-skills\u002Ftree\u002FHEAD\u002Fskills\u002Finngest-middleware","---\nname: inngest-middleware\ndescription: Use when adding cross-cutting concerns to durable functions — structured logging or tracing across all functions, error tracking with Sentry, payload encryption for sensitive data, dependency injection of clients (DB, Stripe, etc.) into function handlers, custom telemetry, or behavior that should apply uniformly across many functions. Covers Inngest middleware lifecycle, creating custom middleware, dependencyInjectionMiddleware, @inngest\u002Fmiddleware-encryption, @inngest\u002Fmiddleware-sentry, and custom middleware patterns.\n---\n\n# Inngest Middleware\n\nMaster Inngest middleware to handle cross-cutting concerns like logging, error tracking, dependency injection, and data transformation. Middleware runs at key points in the function lifecycle, enabling powerful patterns for observability and shared functionality.\n\n> **These skills are focused on TypeScript.** For Python or Go, refer to the [Inngest documentation](https:\u002F\u002Fwww.inngest.com\u002Fllms.txt) for language-specific guidance. Core concepts apply across all languages.\n\n> **Note:** The middleware system was significantly rewritten in v4. The lifecycle hooks documented here reflect the v4 API. If migrating from v3, consult the [migration guide](https:\u002F\u002Fwww.inngest.com\u002Fdocs-markdown\u002Freference\u002Ftypescript\u002Fv4\u002Fmigrations\u002Fv3-to-v4) for details on breaking changes.\n\n> **⚠ For Realtime use the `inngest-realtime` skill, NOT this one.** Inngest v3 used `realtimeMiddleware()` from `@inngest\u002Frealtime` to inject a `publish` arg into function handlers. **v4 ships realtime natively** — `step.realtime.publish` is built-in, no middleware required. Do NOT install `@inngest\u002Frealtime` on a v4 project (it's a v3-era package and produces `TypeError: Cls is not a constructor` at runtime). See the `inngest-realtime` skill for the v4 pattern.\n\n## What is Middleware?\n\nMiddleware allows code to run at various points in an Inngest client's lifecycle - during function execution, event sending, and more. Think of middleware as hooks into the Inngest execution pipeline.\n\n**When to use middleware:**\n\n- **Observability:** Add logging, tracing, or metrics\n- **Dependency injection:** Share client instances across functions\n- **Data transformation:** Encrypt\u002Fdecrypt, validate, or enrich data\n- **Error handling:** Custom error tracking and alerting\n- **Authentication:** Validate user context or permissions\n\n## Middleware Lifecycle\n\nMiddleware can be registered at **client-level** (affects all functions) or **function-level** (affects specific functions).\n\n### Execution Order\n\n```typescript\nconst inngest = new Inngest({\n  id: \"my-app\",\n  middleware: [\n    loggingMiddleware, \u002F\u002F Runs 1st\n    errorMiddleware \u002F\u002F Runs 2nd\n  ]\n});\n\ninngest.createFunction(\n  {\n    id: \"example\",\n    middleware: [\n      authMiddleware, \u002F\u002F Runs 3rd\n      metricsMiddleware \u002F\u002F Runs 4th\n    ],\n    triggers: [{ event: \"test\" }]\n  },\n  async () => {\n    \u002F* function code *\u002F\n  }\n);\n```\n\n**Order matters:** Client middleware runs first, then function middleware, in the order specified.\n\n## Creating Custom Middleware\n\n### Basic Middleware Structure\n\n```typescript\nimport { InngestMiddleware } from \"inngest\";\n\nconst loggingMiddleware = new InngestMiddleware({\n  name: \"Logging Middleware\",\n  init() {\n    \u002F\u002F Setup phase - runs when client initializes\n    const logger = setupLogger();\n\n    return {\n      \u002F\u002F Function execution lifecycle\n      \u002F\u002F Note: `fn` is loosely typed in middleware generics; fn.id works at runtime\n      onFunctionRun({ ctx, fn }) {\n        return {\n          beforeExecution() {\n            logger.info(\"Function starting\", {\n              functionId: fn.id,\n              eventName: ctx.event.name,\n              runId: ctx.runId\n            });\n          },\n\n          afterExecution() {\n            logger.info(\"Function completed\", {\n              functionId: fn.id,\n              runId: ctx.runId\n            });\n          },\n\n          transformOutput({ result }) {\n            \u002F\u002F Log function output\n            logger.debug(\"Function output\", {\n              functionId: fn.id,\n              output: result.data\n            });\n\n            \u002F\u002F Return unmodified result\n            return { result };\n          }\n        };\n      },\n\n      \u002F\u002F Event sending lifecycle\n      onSendEvent() {\n        return {\n          transformInput({ payloads }) {\n            logger.info(\"Sending events\", {\n              count: payloads.length,\n              events: payloads.map((p) => p.name)\n            });\n\n            \u002F\u002F Spread to convert readonly array to mutable array\n            return { payloads: [...payloads] };\n          }\n        };\n      }\n    };\n  }\n});\n```\n\n### Python Implementation\n\nPython middleware follows a similar pattern. See [Dependency Injection Reference](.\u002Freferences\u002Fdependency-injection.md) for complete Python examples.\n\n````\n\n## Dependency Injection\n\nShare expensive or stateful clients across all functions. **See [Dependency Injection Reference](.\u002Freferences\u002Fdependency-injection.md) for detailed patterns.**\n\n### Quick Example - Built-in DI\n\n```typescript\nimport { dependencyInjectionMiddleware } from \"inngest\";\n\nconst inngest = new Inngest({\n  id: 'my-app',\n  middleware: [\n    dependencyInjectionMiddleware({\n      openai: new OpenAI(),\n      db: new PrismaClient(),\n    }),\n  ],\n});\n\n\u002F\u002F Functions automatically get injected dependencies\ninngest.createFunction(\n  { id: \"ai-summary\", triggers: [{ event: \"document\u002Fuploaded\" }] },\n  async ({ event, openai, db }) => {\n    \u002F\u002F Dependencies available in function context\n    const summary = await openai.chat.completions.create({\n      messages: [{ role: \"user\", content: event.data.content }],\n      model: \"gpt-4\",\n    });\n\n    await db.document.update({\n      where: { id: event.data.documentId },\n      data: { summary: summary.choices[0].message.content }\n    });\n  }\n);\n````\n\n## Middleware Packages\n\nBeyond `dependencyInjectionMiddleware` (built-in, shown above), Inngest provides official middleware as **separate packages**. **See [Middleware Reference](.\u002Freferences\u002Fbuilt-in-middleware.md) for complete details.**\n\n### Encryption Middleware\n\n```bash\nnpm install @inngest\u002Fmiddleware-encryption\n```\n\n```typescript\nimport { encryptionMiddleware } from \"@inngest\u002Fmiddleware-encryption\";\n\nconst inngest = new Inngest({\n  id: \"my-app\",\n  middleware: [\n    encryptionMiddleware({\n      key: process.env.ENCRYPTION_KEY\n    })\n  ]\n});\n```\n\nAutomatically encrypts all step data, function output, and event `data.encrypted` field. Supports key rotation via `fallbackDecryptionKeys`.\n\n### Sentry Error Tracking\n\n```bash\nnpm install @inngest\u002Fmiddleware-sentry\n```\n\n```typescript\nimport * as Sentry from \"@sentry\u002Fnode\";\nimport { sentryMiddleware } from \"@inngest\u002Fmiddleware-sentry\";\n\nSentry.init({\n  \u002F* your Sentry config *\u002F\n});\n\nconst inngest = new Inngest({\n  id: \"my-app\",\n  middleware: [sentryMiddleware()]\n});\n```\n\nCaptures exceptions, adds tracing to each function run, and includes function ID and event names as context. Requires `@sentry\u002F*@>=8.0.0`.\n\n## Common Middleware Patterns\n\n### Metrics and Performance Tracking\n\n```typescript\nconst metricsMiddleware = new InngestMiddleware({\n  name: \"Metrics Tracking\",\n  init() {\n    return {\n      onFunctionRun({ ctx, fn }) {\n        let startTime: number;\n\n        return {\n          beforeExecution() {\n            startTime = Date.now();\n            metrics.increment(\"inngest.step.started\", {\n              function: fn.id,\n              event: ctx.event.name\n            });\n          },\n\n          afterExecution() {\n            const duration = Date.now() - startTime;\n            metrics.histogram(\"inngest.step.duration\", duration, {\n              function: fn.id,\n              event: ctx.event.name\n            });\n          },\n\n          transformOutput({ result }) {\n            const status = result.error ? \"error\" : \"success\";\n            metrics.increment(\"inngest.step.completed\", {\n              function: fn.id,\n              status: status\n            });\n\n            return { result };\n          }\n        };\n      }\n    };\n  }\n});\n```\n\n### Advanced Patterns\n\n**Authentication:** Validate tokens and inject user context\n**Conditional logic:** Apply middleware based on event type or function\n**Circuit breakers:** Prevent cascading failures from external services\n\n### Configuration-Based Middleware\n\nCreate reusable middleware with configuration options for different environments and use cases. See reference documentation for complete examples.\n\n## Best Practices\n\n### Design Principles\n\n1. **Keep middleware focused:** One concern per middleware\n2. **Handle errors gracefully:** Don't let middleware crash functions\n3. **Consider performance:** Middleware runs on every execution\n4. **Use proper typing:** Let TypeScript infer middleware types\n5. **Test thoroughly:** Middleware affects all functions that use it\n\n### Common Use Cases to Implement\n\n- **Retry logic** for transient failures\n- **Circuit breakers** for external service calls\n- **Request\u002Fresponse logging** for debugging\n- **User context enrichment** from external sources\n- **Feature flags** for gradual rollouts\n- **Custom authentication** and authorization checks\n\n### Error Handling in Middleware\n\n```typescript\nconst robustMiddleware = new InngestMiddleware({\n  name: \"Robust Middleware\",\n  init() {\n    return {\n      onFunctionRun({ ctx, fn }) {\n        return {\n          transformOutput({ result }) {\n            try {\n              \u002F\u002F Your middleware logic here\n              return performTransformation(result);\n            } catch (middlewareError) {\n              \u002F\u002F Log error but don't break the function\n              console.error(\"Middleware error:\", middlewareError);\n\n              \u002F\u002F Return original result on middleware failure\n              return { result };\n            }\n          }\n        };\n      }\n    };\n  }\n});\n```\n\n### Testing Middleware\n\nUse Inngest's testing utilities (`createMockContext`, `createMockFunction`) to unit test middleware behavior.\n\n**For complete implementation examples and advanced patterns, see:**\n\n- [Dependency Injection Reference](.\u002Freferences\u002Fdependency-injection.md)\n- [Built-in Middleware Reference](.\u002Freferences\u002Fbuilt-in-middleware.md)\n",{"data":45,"body":46},{"name":4,"description":6},{"type":47,"children":48},"root",[49,57,63,89,111,194,201,206,214,269,275,294,301,724,734,740,746,1882,1888,1901,1911,1917,1950,1956,1984,2197,2217,2223,2246,2497,2509,2515,2521,3334,3340,3363,3369,3374,3380,3386,3440,3446,3509,3515,3904,3910,3931,3939,3957],{"type":50,"tag":51,"props":52,"children":53},"element","h1",{"id":4},[54],{"type":55,"value":56},"text","Inngest Middleware",{"type":50,"tag":58,"props":59,"children":60},"p",{},[61],{"type":55,"value":62},"Master Inngest middleware to handle cross-cutting concerns like logging, error tracking, dependency injection, and data transformation. Middleware runs at key points in the function lifecycle, enabling powerful patterns for observability and shared functionality.",{"type":50,"tag":64,"props":65,"children":66},"blockquote",{},[67],{"type":50,"tag":58,"props":68,"children":69},{},[70,76,78,87],{"type":50,"tag":71,"props":72,"children":73},"strong",{},[74],{"type":55,"value":75},"These skills are focused on TypeScript.",{"type":55,"value":77}," For Python or Go, refer to the ",{"type":50,"tag":79,"props":80,"children":84},"a",{"href":81,"rel":82},"https:\u002F\u002Fwww.inngest.com\u002Fllms.txt",[83],"nofollow",[85],{"type":55,"value":86},"Inngest documentation",{"type":55,"value":88}," for language-specific guidance. Core concepts apply across all languages.",{"type":50,"tag":64,"props":90,"children":91},{},[92],{"type":50,"tag":58,"props":93,"children":94},{},[95,100,102,109],{"type":50,"tag":71,"props":96,"children":97},{},[98],{"type":55,"value":99},"Note:",{"type":55,"value":101}," The middleware system was significantly rewritten in v4. The lifecycle hooks documented here reflect the v4 API. If migrating from v3, consult the ",{"type":50,"tag":79,"props":103,"children":106},{"href":104,"rel":105},"https:\u002F\u002Fwww.inngest.com\u002Fdocs-markdown\u002Freference\u002Ftypescript\u002Fv4\u002Fmigrations\u002Fv3-to-v4",[83],[107],{"type":55,"value":108},"migration guide",{"type":55,"value":110}," for details on breaking changes.",{"type":50,"tag":64,"props":112,"children":113},{},[114],{"type":50,"tag":58,"props":115,"children":116},{},[117,131,133,139,141,147,149,155,157,162,164,170,172,177,179,185,187,192],{"type":50,"tag":71,"props":118,"children":119},{},[120,122,129],{"type":55,"value":121},"⚠ For Realtime use the ",{"type":50,"tag":123,"props":124,"children":126},"code",{"className":125},[],[127],{"type":55,"value":128},"inngest-realtime",{"type":55,"value":130}," skill, NOT this one.",{"type":55,"value":132}," Inngest v3 used ",{"type":50,"tag":123,"props":134,"children":136},{"className":135},[],[137],{"type":55,"value":138},"realtimeMiddleware()",{"type":55,"value":140}," from ",{"type":50,"tag":123,"props":142,"children":144},{"className":143},[],[145],{"type":55,"value":146},"@inngest\u002Frealtime",{"type":55,"value":148}," to inject a ",{"type":50,"tag":123,"props":150,"children":152},{"className":151},[],[153],{"type":55,"value":154},"publish",{"type":55,"value":156}," arg into function handlers. ",{"type":50,"tag":71,"props":158,"children":159},{},[160],{"type":55,"value":161},"v4 ships realtime natively",{"type":55,"value":163}," — ",{"type":50,"tag":123,"props":165,"children":167},{"className":166},[],[168],{"type":55,"value":169},"step.realtime.publish",{"type":55,"value":171}," is built-in, no middleware required. Do NOT install ",{"type":50,"tag":123,"props":173,"children":175},{"className":174},[],[176],{"type":55,"value":146},{"type":55,"value":178}," on a v4 project (it's a v3-era package and produces ",{"type":50,"tag":123,"props":180,"children":182},{"className":181},[],[183],{"type":55,"value":184},"TypeError: Cls is not a constructor",{"type":55,"value":186}," at runtime). See the ",{"type":50,"tag":123,"props":188,"children":190},{"className":189},[],[191],{"type":55,"value":128},{"type":55,"value":193}," skill for the v4 pattern.",{"type":50,"tag":195,"props":196,"children":198},"h2",{"id":197},"what-is-middleware",[199],{"type":55,"value":200},"What is Middleware?",{"type":50,"tag":58,"props":202,"children":203},{},[204],{"type":55,"value":205},"Middleware allows code to run at various points in an Inngest client's lifecycle - during function execution, event sending, and more. Think of middleware as hooks into the Inngest execution pipeline.",{"type":50,"tag":58,"props":207,"children":208},{},[209],{"type":50,"tag":71,"props":210,"children":211},{},[212],{"type":55,"value":213},"When to use middleware:",{"type":50,"tag":215,"props":216,"children":217},"ul",{},[218,229,239,249,259],{"type":50,"tag":219,"props":220,"children":221},"li",{},[222,227],{"type":50,"tag":71,"props":223,"children":224},{},[225],{"type":55,"value":226},"Observability:",{"type":55,"value":228}," Add logging, tracing, or metrics",{"type":50,"tag":219,"props":230,"children":231},{},[232,237],{"type":50,"tag":71,"props":233,"children":234},{},[235],{"type":55,"value":236},"Dependency injection:",{"type":55,"value":238}," Share client instances across functions",{"type":50,"tag":219,"props":240,"children":241},{},[242,247],{"type":50,"tag":71,"props":243,"children":244},{},[245],{"type":55,"value":246},"Data transformation:",{"type":55,"value":248}," Encrypt\u002Fdecrypt, validate, or enrich data",{"type":50,"tag":219,"props":250,"children":251},{},[252,257],{"type":50,"tag":71,"props":253,"children":254},{},[255],{"type":55,"value":256},"Error handling:",{"type":55,"value":258}," Custom error tracking and alerting",{"type":50,"tag":219,"props":260,"children":261},{},[262,267],{"type":50,"tag":71,"props":263,"children":264},{},[265],{"type":55,"value":266},"Authentication:",{"type":55,"value":268}," Validate user context or permissions",{"type":50,"tag":195,"props":270,"children":272},{"id":271},"middleware-lifecycle",[273],{"type":55,"value":274},"Middleware Lifecycle",{"type":50,"tag":58,"props":276,"children":277},{},[278,280,285,287,292],{"type":55,"value":279},"Middleware can be registered at ",{"type":50,"tag":71,"props":281,"children":282},{},[283],{"type":55,"value":284},"client-level",{"type":55,"value":286}," (affects all functions) or ",{"type":50,"tag":71,"props":288,"children":289},{},[290],{"type":55,"value":291},"function-level",{"type":55,"value":293}," (affects specific functions).",{"type":50,"tag":295,"props":296,"children":298},"h3",{"id":297},"execution-order",[299],{"type":55,"value":300},"Execution Order",{"type":50,"tag":302,"props":303,"children":308},"pre",{"className":304,"code":305,"language":306,"meta":307,"style":307},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","const inngest = new Inngest({\n  id: \"my-app\",\n  middleware: [\n    loggingMiddleware, \u002F\u002F Runs 1st\n    errorMiddleware \u002F\u002F Runs 2nd\n  ]\n});\n\ninngest.createFunction(\n  {\n    id: \"example\",\n    middleware: [\n      authMiddleware, \u002F\u002F Runs 3rd\n      metricsMiddleware \u002F\u002F Runs 4th\n    ],\n    triggers: [{ event: \"test\" }]\n  },\n  async () => {\n    \u002F* function code *\u002F\n  }\n);\n","typescript","",[309],{"type":50,"tag":123,"props":310,"children":311},{"__ignoreMap":307},[312,357,393,411,431,444,453,472,482,505,514,544,561,579,593,606,661,670,694,703,712],{"type":50,"tag":313,"props":314,"children":317},"span",{"class":315,"line":316},"line",1,[318,324,330,336,341,347,352],{"type":50,"tag":313,"props":319,"children":321},{"style":320},"--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA",[322],{"type":55,"value":323},"const",{"type":50,"tag":313,"props":325,"children":327},{"style":326},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[328],{"type":55,"value":329}," inngest ",{"type":50,"tag":313,"props":331,"children":333},{"style":332},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[334],{"type":55,"value":335},"=",{"type":50,"tag":313,"props":337,"children":338},{"style":332},[339],{"type":55,"value":340}," new",{"type":50,"tag":313,"props":342,"children":344},{"style":343},"--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF",[345],{"type":55,"value":346}," Inngest",{"type":50,"tag":313,"props":348,"children":349},{"style":326},[350],{"type":55,"value":351},"(",{"type":50,"tag":313,"props":353,"children":354},{"style":332},[355],{"type":55,"value":356},"{\n",{"type":50,"tag":313,"props":358,"children":360},{"class":315,"line":359},2,[361,367,372,377,383,388],{"type":50,"tag":313,"props":362,"children":364},{"style":363},"--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178",[365],{"type":55,"value":366},"  id",{"type":50,"tag":313,"props":368,"children":369},{"style":332},[370],{"type":55,"value":371},":",{"type":50,"tag":313,"props":373,"children":374},{"style":332},[375],{"type":55,"value":376}," \"",{"type":50,"tag":313,"props":378,"children":380},{"style":379},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[381],{"type":55,"value":382},"my-app",{"type":50,"tag":313,"props":384,"children":385},{"style":332},[386],{"type":55,"value":387},"\"",{"type":50,"tag":313,"props":389,"children":390},{"style":332},[391],{"type":55,"value":392},",\n",{"type":50,"tag":313,"props":394,"children":396},{"class":315,"line":395},3,[397,402,406],{"type":50,"tag":313,"props":398,"children":399},{"style":363},[400],{"type":55,"value":401},"  middleware",{"type":50,"tag":313,"props":403,"children":404},{"style":332},[405],{"type":55,"value":371},{"type":50,"tag":313,"props":407,"children":408},{"style":326},[409],{"type":55,"value":410}," [\n",{"type":50,"tag":313,"props":412,"children":414},{"class":315,"line":413},4,[415,420,425],{"type":50,"tag":313,"props":416,"children":417},{"style":326},[418],{"type":55,"value":419},"    loggingMiddleware",{"type":50,"tag":313,"props":421,"children":422},{"style":332},[423],{"type":55,"value":424},",",{"type":50,"tag":313,"props":426,"children":428},{"style":427},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[429],{"type":55,"value":430}," \u002F\u002F Runs 1st\n",{"type":50,"tag":313,"props":432,"children":433},{"class":315,"line":30},[434,439],{"type":50,"tag":313,"props":435,"children":436},{"style":326},[437],{"type":55,"value":438},"    errorMiddleware ",{"type":50,"tag":313,"props":440,"children":441},{"style":427},[442],{"type":55,"value":443},"\u002F\u002F Runs 2nd\n",{"type":50,"tag":313,"props":445,"children":447},{"class":315,"line":446},6,[448],{"type":50,"tag":313,"props":449,"children":450},{"style":326},[451],{"type":55,"value":452},"  ]\n",{"type":50,"tag":313,"props":454,"children":456},{"class":315,"line":455},7,[457,462,467],{"type":50,"tag":313,"props":458,"children":459},{"style":332},[460],{"type":55,"value":461},"}",{"type":50,"tag":313,"props":463,"children":464},{"style":326},[465],{"type":55,"value":466},")",{"type":50,"tag":313,"props":468,"children":469},{"style":332},[470],{"type":55,"value":471},";\n",{"type":50,"tag":313,"props":473,"children":475},{"class":315,"line":474},8,[476],{"type":50,"tag":313,"props":477,"children":479},{"emptyLinePlaceholder":478},true,[480],{"type":55,"value":481},"\n",{"type":50,"tag":313,"props":483,"children":485},{"class":315,"line":484},9,[486,490,495,500],{"type":50,"tag":313,"props":487,"children":488},{"style":326},[489],{"type":55,"value":8},{"type":50,"tag":313,"props":491,"children":492},{"style":332},[493],{"type":55,"value":494},".",{"type":50,"tag":313,"props":496,"children":497},{"style":343},[498],{"type":55,"value":499},"createFunction",{"type":50,"tag":313,"props":501,"children":502},{"style":326},[503],{"type":55,"value":504},"(\n",{"type":50,"tag":313,"props":506,"children":508},{"class":315,"line":507},10,[509],{"type":50,"tag":313,"props":510,"children":511},{"style":332},[512],{"type":55,"value":513},"  {\n",{"type":50,"tag":313,"props":515,"children":517},{"class":315,"line":516},11,[518,523,527,531,536,540],{"type":50,"tag":313,"props":519,"children":520},{"style":363},[521],{"type":55,"value":522},"    id",{"type":50,"tag":313,"props":524,"children":525},{"style":332},[526],{"type":55,"value":371},{"type":50,"tag":313,"props":528,"children":529},{"style":332},[530],{"type":55,"value":376},{"type":50,"tag":313,"props":532,"children":533},{"style":379},[534],{"type":55,"value":535},"example",{"type":50,"tag":313,"props":537,"children":538},{"style":332},[539],{"type":55,"value":387},{"type":50,"tag":313,"props":541,"children":542},{"style":332},[543],{"type":55,"value":392},{"type":50,"tag":313,"props":545,"children":547},{"class":315,"line":546},12,[548,553,557],{"type":50,"tag":313,"props":549,"children":550},{"style":363},[551],{"type":55,"value":552},"    middleware",{"type":50,"tag":313,"props":554,"children":555},{"style":332},[556],{"type":55,"value":371},{"type":50,"tag":313,"props":558,"children":559},{"style":326},[560],{"type":55,"value":410},{"type":50,"tag":313,"props":562,"children":564},{"class":315,"line":563},13,[565,570,574],{"type":50,"tag":313,"props":566,"children":567},{"style":326},[568],{"type":55,"value":569},"      authMiddleware",{"type":50,"tag":313,"props":571,"children":572},{"style":332},[573],{"type":55,"value":424},{"type":50,"tag":313,"props":575,"children":576},{"style":427},[577],{"type":55,"value":578}," \u002F\u002F Runs 3rd\n",{"type":50,"tag":313,"props":580,"children":582},{"class":315,"line":581},14,[583,588],{"type":50,"tag":313,"props":584,"children":585},{"style":326},[586],{"type":55,"value":587},"      metricsMiddleware ",{"type":50,"tag":313,"props":589,"children":590},{"style":427},[591],{"type":55,"value":592},"\u002F\u002F Runs 4th\n",{"type":50,"tag":313,"props":594,"children":596},{"class":315,"line":595},15,[597,602],{"type":50,"tag":313,"props":598,"children":599},{"style":326},[600],{"type":55,"value":601},"    ]",{"type":50,"tag":313,"props":603,"children":604},{"style":332},[605],{"type":55,"value":392},{"type":50,"tag":313,"props":607,"children":609},{"class":315,"line":608},16,[610,615,619,624,629,634,638,642,647,651,656],{"type":50,"tag":313,"props":611,"children":612},{"style":363},[613],{"type":55,"value":614},"    triggers",{"type":50,"tag":313,"props":616,"children":617},{"style":332},[618],{"type":55,"value":371},{"type":50,"tag":313,"props":620,"children":621},{"style":326},[622],{"type":55,"value":623}," [",{"type":50,"tag":313,"props":625,"children":626},{"style":332},[627],{"type":55,"value":628},"{",{"type":50,"tag":313,"props":630,"children":631},{"style":363},[632],{"type":55,"value":633}," event",{"type":50,"tag":313,"props":635,"children":636},{"style":332},[637],{"type":55,"value":371},{"type":50,"tag":313,"props":639,"children":640},{"style":332},[641],{"type":55,"value":376},{"type":50,"tag":313,"props":643,"children":644},{"style":379},[645],{"type":55,"value":646},"test",{"type":50,"tag":313,"props":648,"children":649},{"style":332},[650],{"type":55,"value":387},{"type":50,"tag":313,"props":652,"children":653},{"style":332},[654],{"type":55,"value":655}," }",{"type":50,"tag":313,"props":657,"children":658},{"style":326},[659],{"type":55,"value":660},"]\n",{"type":50,"tag":313,"props":662,"children":664},{"class":315,"line":663},17,[665],{"type":50,"tag":313,"props":666,"children":667},{"style":332},[668],{"type":55,"value":669},"  },\n",{"type":50,"tag":313,"props":671,"children":673},{"class":315,"line":672},18,[674,679,684,689],{"type":50,"tag":313,"props":675,"children":676},{"style":320},[677],{"type":55,"value":678},"  async",{"type":50,"tag":313,"props":680,"children":681},{"style":332},[682],{"type":55,"value":683}," ()",{"type":50,"tag":313,"props":685,"children":686},{"style":320},[687],{"type":55,"value":688}," =>",{"type":50,"tag":313,"props":690,"children":691},{"style":332},[692],{"type":55,"value":693}," {\n",{"type":50,"tag":313,"props":695,"children":697},{"class":315,"line":696},19,[698],{"type":50,"tag":313,"props":699,"children":700},{"style":427},[701],{"type":55,"value":702},"    \u002F* function code *\u002F\n",{"type":50,"tag":313,"props":704,"children":706},{"class":315,"line":705},20,[707],{"type":50,"tag":313,"props":708,"children":709},{"style":332},[710],{"type":55,"value":711},"  }\n",{"type":50,"tag":313,"props":713,"children":715},{"class":315,"line":714},21,[716,720],{"type":50,"tag":313,"props":717,"children":718},{"style":326},[719],{"type":55,"value":466},{"type":50,"tag":313,"props":721,"children":722},{"style":332},[723],{"type":55,"value":471},{"type":50,"tag":58,"props":725,"children":726},{},[727,732],{"type":50,"tag":71,"props":728,"children":729},{},[730],{"type":55,"value":731},"Order matters:",{"type":55,"value":733}," Client middleware runs first, then function middleware, in the order specified.",{"type":50,"tag":195,"props":735,"children":737},{"id":736},"creating-custom-middleware",[738],{"type":55,"value":739},"Creating Custom Middleware",{"type":50,"tag":295,"props":741,"children":743},{"id":742},"basic-middleware-structure",[744],{"type":55,"value":745},"Basic Middleware Structure",{"type":50,"tag":302,"props":747,"children":749},{"className":304,"code":748,"language":306,"meta":307,"style":307},"import { InngestMiddleware } from \"inngest\";\n\nconst loggingMiddleware = new InngestMiddleware({\n  name: \"Logging Middleware\",\n  init() {\n    \u002F\u002F Setup phase - runs when client initializes\n    const logger = setupLogger();\n\n    return {\n      \u002F\u002F Function execution lifecycle\n      \u002F\u002F Note: `fn` is loosely typed in middleware generics; fn.id works at runtime\n      onFunctionRun({ ctx, fn }) {\n        return {\n          beforeExecution() {\n            logger.info(\"Function starting\", {\n              functionId: fn.id,\n              eventName: ctx.event.name,\n              runId: ctx.runId\n            });\n          },\n\n          afterExecution() {\n            logger.info(\"Function completed\", {\n              functionId: fn.id,\n              runId: ctx.runId\n            });\n          },\n\n          transformOutput({ result }) {\n            \u002F\u002F Log function output\n            logger.debug(\"Function output\", {\n              functionId: fn.id,\n              output: result.data\n            });\n\n            \u002F\u002F Return unmodified result\n            return { result };\n          }\n        };\n      },\n\n      \u002F\u002F Event sending lifecycle\n      onSendEvent() {\n        return {\n          transformInput({ payloads }) {\n            logger.info(\"Sending events\", {\n              count: payloads.length,\n              events: payloads.map((p) => p.name)\n            });\n\n            \u002F\u002F Spread to convert readonly array to mutable array\n            return { payloads: [...payloads] };\n          }\n        };\n      }\n    };\n  }\n});\n",[750],{"type":50,"tag":123,"props":751,"children":752},{"__ignoreMap":307},[753,797,804,836,865,882,890,921,928,940,948,956,993,1005,1021,1063,1092,1130,1155,1171,1179,1186,1203,1244,1272,1296,1311,1319,1327,1353,1362,1404,1432,1458,1474,1482,1491,1513,1522,1531,1540,1548,1557,1574,1586,1612,1653,1683,1747,1763,1771,1780,1824,1832,1840,1849,1858,1866],{"type":50,"tag":313,"props":754,"children":755},{"class":315,"line":316},[756,762,767,772,776,781,785,789,793],{"type":50,"tag":313,"props":757,"children":759},{"style":758},"--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic",[760],{"type":55,"value":761},"import",{"type":50,"tag":313,"props":763,"children":764},{"style":332},[765],{"type":55,"value":766}," {",{"type":50,"tag":313,"props":768,"children":769},{"style":326},[770],{"type":55,"value":771}," InngestMiddleware",{"type":50,"tag":313,"props":773,"children":774},{"style":332},[775],{"type":55,"value":655},{"type":50,"tag":313,"props":777,"children":778},{"style":758},[779],{"type":55,"value":780}," from",{"type":50,"tag":313,"props":782,"children":783},{"style":332},[784],{"type":55,"value":376},{"type":50,"tag":313,"props":786,"children":787},{"style":379},[788],{"type":55,"value":8},{"type":50,"tag":313,"props":790,"children":791},{"style":332},[792],{"type":55,"value":387},{"type":50,"tag":313,"props":794,"children":795},{"style":332},[796],{"type":55,"value":471},{"type":50,"tag":313,"props":798,"children":799},{"class":315,"line":359},[800],{"type":50,"tag":313,"props":801,"children":802},{"emptyLinePlaceholder":478},[803],{"type":55,"value":481},{"type":50,"tag":313,"props":805,"children":806},{"class":315,"line":395},[807,811,816,820,824,828,832],{"type":50,"tag":313,"props":808,"children":809},{"style":320},[810],{"type":55,"value":323},{"type":50,"tag":313,"props":812,"children":813},{"style":326},[814],{"type":55,"value":815}," loggingMiddleware ",{"type":50,"tag":313,"props":817,"children":818},{"style":332},[819],{"type":55,"value":335},{"type":50,"tag":313,"props":821,"children":822},{"style":332},[823],{"type":55,"value":340},{"type":50,"tag":313,"props":825,"children":826},{"style":343},[827],{"type":55,"value":771},{"type":50,"tag":313,"props":829,"children":830},{"style":326},[831],{"type":55,"value":351},{"type":50,"tag":313,"props":833,"children":834},{"style":332},[835],{"type":55,"value":356},{"type":50,"tag":313,"props":837,"children":838},{"class":315,"line":413},[839,844,848,852,857,861],{"type":50,"tag":313,"props":840,"children":841},{"style":363},[842],{"type":55,"value":843},"  name",{"type":50,"tag":313,"props":845,"children":846},{"style":332},[847],{"type":55,"value":371},{"type":50,"tag":313,"props":849,"children":850},{"style":332},[851],{"type":55,"value":376},{"type":50,"tag":313,"props":853,"children":854},{"style":379},[855],{"type":55,"value":856},"Logging Middleware",{"type":50,"tag":313,"props":858,"children":859},{"style":332},[860],{"type":55,"value":387},{"type":50,"tag":313,"props":862,"children":863},{"style":332},[864],{"type":55,"value":392},{"type":50,"tag":313,"props":866,"children":867},{"class":315,"line":30},[868,873,878],{"type":50,"tag":313,"props":869,"children":870},{"style":363},[871],{"type":55,"value":872},"  init",{"type":50,"tag":313,"props":874,"children":875},{"style":332},[876],{"type":55,"value":877},"()",{"type":50,"tag":313,"props":879,"children":880},{"style":332},[881],{"type":55,"value":693},{"type":50,"tag":313,"props":883,"children":884},{"class":315,"line":446},[885],{"type":50,"tag":313,"props":886,"children":887},{"style":427},[888],{"type":55,"value":889},"    \u002F\u002F Setup phase - runs when client initializes\n",{"type":50,"tag":313,"props":891,"children":892},{"class":315,"line":455},[893,898,903,908,913,917],{"type":50,"tag":313,"props":894,"children":895},{"style":320},[896],{"type":55,"value":897},"    const",{"type":50,"tag":313,"props":899,"children":900},{"style":326},[901],{"type":55,"value":902}," logger",{"type":50,"tag":313,"props":904,"children":905},{"style":332},[906],{"type":55,"value":907}," =",{"type":50,"tag":313,"props":909,"children":910},{"style":343},[911],{"type":55,"value":912}," setupLogger",{"type":50,"tag":313,"props":914,"children":915},{"style":363},[916],{"type":55,"value":877},{"type":50,"tag":313,"props":918,"children":919},{"style":332},[920],{"type":55,"value":471},{"type":50,"tag":313,"props":922,"children":923},{"class":315,"line":474},[924],{"type":50,"tag":313,"props":925,"children":926},{"emptyLinePlaceholder":478},[927],{"type":55,"value":481},{"type":50,"tag":313,"props":929,"children":930},{"class":315,"line":484},[931,936],{"type":50,"tag":313,"props":932,"children":933},{"style":758},[934],{"type":55,"value":935},"    return",{"type":50,"tag":313,"props":937,"children":938},{"style":332},[939],{"type":55,"value":693},{"type":50,"tag":313,"props":941,"children":942},{"class":315,"line":507},[943],{"type":50,"tag":313,"props":944,"children":945},{"style":427},[946],{"type":55,"value":947},"      \u002F\u002F Function execution lifecycle\n",{"type":50,"tag":313,"props":949,"children":950},{"class":315,"line":516},[951],{"type":50,"tag":313,"props":952,"children":953},{"style":427},[954],{"type":55,"value":955},"      \u002F\u002F Note: `fn` is loosely typed in middleware generics; fn.id works at runtime\n",{"type":50,"tag":313,"props":957,"children":958},{"class":315,"line":546},[959,964,969,975,979,984,989],{"type":50,"tag":313,"props":960,"children":961},{"style":363},[962],{"type":55,"value":963},"      onFunctionRun",{"type":50,"tag":313,"props":965,"children":966},{"style":332},[967],{"type":55,"value":968},"({",{"type":50,"tag":313,"props":970,"children":972},{"style":971},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic",[973],{"type":55,"value":974}," ctx",{"type":50,"tag":313,"props":976,"children":977},{"style":332},[978],{"type":55,"value":424},{"type":50,"tag":313,"props":980,"children":981},{"style":971},[982],{"type":55,"value":983}," fn",{"type":50,"tag":313,"props":985,"children":986},{"style":332},[987],{"type":55,"value":988}," })",{"type":50,"tag":313,"props":990,"children":991},{"style":332},[992],{"type":55,"value":693},{"type":50,"tag":313,"props":994,"children":995},{"class":315,"line":563},[996,1001],{"type":50,"tag":313,"props":997,"children":998},{"style":758},[999],{"type":55,"value":1000},"        return",{"type":50,"tag":313,"props":1002,"children":1003},{"style":332},[1004],{"type":55,"value":693},{"type":50,"tag":313,"props":1006,"children":1007},{"class":315,"line":581},[1008,1013,1017],{"type":50,"tag":313,"props":1009,"children":1010},{"style":363},[1011],{"type":55,"value":1012},"          beforeExecution",{"type":50,"tag":313,"props":1014,"children":1015},{"style":332},[1016],{"type":55,"value":877},{"type":50,"tag":313,"props":1018,"children":1019},{"style":332},[1020],{"type":55,"value":693},{"type":50,"tag":313,"props":1022,"children":1023},{"class":315,"line":595},[1024,1029,1033,1038,1042,1046,1051,1055,1059],{"type":50,"tag":313,"props":1025,"children":1026},{"style":326},[1027],{"type":55,"value":1028},"            logger",{"type":50,"tag":313,"props":1030,"children":1031},{"style":332},[1032],{"type":55,"value":494},{"type":50,"tag":313,"props":1034,"children":1035},{"style":343},[1036],{"type":55,"value":1037},"info",{"type":50,"tag":313,"props":1039,"children":1040},{"style":363},[1041],{"type":55,"value":351},{"type":50,"tag":313,"props":1043,"children":1044},{"style":332},[1045],{"type":55,"value":387},{"type":50,"tag":313,"props":1047,"children":1048},{"style":379},[1049],{"type":55,"value":1050},"Function starting",{"type":50,"tag":313,"props":1052,"children":1053},{"style":332},[1054],{"type":55,"value":387},{"type":50,"tag":313,"props":1056,"children":1057},{"style":332},[1058],{"type":55,"value":424},{"type":50,"tag":313,"props":1060,"children":1061},{"style":332},[1062],{"type":55,"value":693},{"type":50,"tag":313,"props":1064,"children":1065},{"class":315,"line":608},[1066,1071,1075,1079,1083,1088],{"type":50,"tag":313,"props":1067,"children":1068},{"style":363},[1069],{"type":55,"value":1070},"              functionId",{"type":50,"tag":313,"props":1072,"children":1073},{"style":332},[1074],{"type":55,"value":371},{"type":50,"tag":313,"props":1076,"children":1077},{"style":326},[1078],{"type":55,"value":983},{"type":50,"tag":313,"props":1080,"children":1081},{"style":332},[1082],{"type":55,"value":494},{"type":50,"tag":313,"props":1084,"children":1085},{"style":326},[1086],{"type":55,"value":1087},"id",{"type":50,"tag":313,"props":1089,"children":1090},{"style":332},[1091],{"type":55,"value":392},{"type":50,"tag":313,"props":1093,"children":1094},{"class":315,"line":663},[1095,1100,1104,1108,1112,1117,1121,1126],{"type":50,"tag":313,"props":1096,"children":1097},{"style":363},[1098],{"type":55,"value":1099},"              eventName",{"type":50,"tag":313,"props":1101,"children":1102},{"style":332},[1103],{"type":55,"value":371},{"type":50,"tag":313,"props":1105,"children":1106},{"style":326},[1107],{"type":55,"value":974},{"type":50,"tag":313,"props":1109,"children":1110},{"style":332},[1111],{"type":55,"value":494},{"type":50,"tag":313,"props":1113,"children":1114},{"style":326},[1115],{"type":55,"value":1116},"event",{"type":50,"tag":313,"props":1118,"children":1119},{"style":332},[1120],{"type":55,"value":494},{"type":50,"tag":313,"props":1122,"children":1123},{"style":326},[1124],{"type":55,"value":1125},"name",{"type":50,"tag":313,"props":1127,"children":1128},{"style":332},[1129],{"type":55,"value":392},{"type":50,"tag":313,"props":1131,"children":1132},{"class":315,"line":672},[1133,1138,1142,1146,1150],{"type":50,"tag":313,"props":1134,"children":1135},{"style":363},[1136],{"type":55,"value":1137},"              runId",{"type":50,"tag":313,"props":1139,"children":1140},{"style":332},[1141],{"type":55,"value":371},{"type":50,"tag":313,"props":1143,"children":1144},{"style":326},[1145],{"type":55,"value":974},{"type":50,"tag":313,"props":1147,"children":1148},{"style":332},[1149],{"type":55,"value":494},{"type":50,"tag":313,"props":1151,"children":1152},{"style":326},[1153],{"type":55,"value":1154},"runId\n",{"type":50,"tag":313,"props":1156,"children":1157},{"class":315,"line":696},[1158,1163,1167],{"type":50,"tag":313,"props":1159,"children":1160},{"style":332},[1161],{"type":55,"value":1162},"            }",{"type":50,"tag":313,"props":1164,"children":1165},{"style":363},[1166],{"type":55,"value":466},{"type":50,"tag":313,"props":1168,"children":1169},{"style":332},[1170],{"type":55,"value":471},{"type":50,"tag":313,"props":1172,"children":1173},{"class":315,"line":705},[1174],{"type":50,"tag":313,"props":1175,"children":1176},{"style":332},[1177],{"type":55,"value":1178},"          },\n",{"type":50,"tag":313,"props":1180,"children":1181},{"class":315,"line":714},[1182],{"type":50,"tag":313,"props":1183,"children":1184},{"emptyLinePlaceholder":478},[1185],{"type":55,"value":481},{"type":50,"tag":313,"props":1187,"children":1189},{"class":315,"line":1188},22,[1190,1195,1199],{"type":50,"tag":313,"props":1191,"children":1192},{"style":363},[1193],{"type":55,"value":1194},"          afterExecution",{"type":50,"tag":313,"props":1196,"children":1197},{"style":332},[1198],{"type":55,"value":877},{"type":50,"tag":313,"props":1200,"children":1201},{"style":332},[1202],{"type":55,"value":693},{"type":50,"tag":313,"props":1204,"children":1206},{"class":315,"line":1205},23,[1207,1211,1215,1219,1223,1227,1232,1236,1240],{"type":50,"tag":313,"props":1208,"children":1209},{"style":326},[1210],{"type":55,"value":1028},{"type":50,"tag":313,"props":1212,"children":1213},{"style":332},[1214],{"type":55,"value":494},{"type":50,"tag":313,"props":1216,"children":1217},{"style":343},[1218],{"type":55,"value":1037},{"type":50,"tag":313,"props":1220,"children":1221},{"style":363},[1222],{"type":55,"value":351},{"type":50,"tag":313,"props":1224,"children":1225},{"style":332},[1226],{"type":55,"value":387},{"type":50,"tag":313,"props":1228,"children":1229},{"style":379},[1230],{"type":55,"value":1231},"Function completed",{"type":50,"tag":313,"props":1233,"children":1234},{"style":332},[1235],{"type":55,"value":387},{"type":50,"tag":313,"props":1237,"children":1238},{"style":332},[1239],{"type":55,"value":424},{"type":50,"tag":313,"props":1241,"children":1242},{"style":332},[1243],{"type":55,"value":693},{"type":50,"tag":313,"props":1245,"children":1247},{"class":315,"line":1246},24,[1248,1252,1256,1260,1264,1268],{"type":50,"tag":313,"props":1249,"children":1250},{"style":363},[1251],{"type":55,"value":1070},{"type":50,"tag":313,"props":1253,"children":1254},{"style":332},[1255],{"type":55,"value":371},{"type":50,"tag":313,"props":1257,"children":1258},{"style":326},[1259],{"type":55,"value":983},{"type":50,"tag":313,"props":1261,"children":1262},{"style":332},[1263],{"type":55,"value":494},{"type":50,"tag":313,"props":1265,"children":1266},{"style":326},[1267],{"type":55,"value":1087},{"type":50,"tag":313,"props":1269,"children":1270},{"style":332},[1271],{"type":55,"value":392},{"type":50,"tag":313,"props":1273,"children":1275},{"class":315,"line":1274},25,[1276,1280,1284,1288,1292],{"type":50,"tag":313,"props":1277,"children":1278},{"style":363},[1279],{"type":55,"value":1137},{"type":50,"tag":313,"props":1281,"children":1282},{"style":332},[1283],{"type":55,"value":371},{"type":50,"tag":313,"props":1285,"children":1286},{"style":326},[1287],{"type":55,"value":974},{"type":50,"tag":313,"props":1289,"children":1290},{"style":332},[1291],{"type":55,"value":494},{"type":50,"tag":313,"props":1293,"children":1294},{"style":326},[1295],{"type":55,"value":1154},{"type":50,"tag":313,"props":1297,"children":1298},{"class":315,"line":26},[1299,1303,1307],{"type":50,"tag":313,"props":1300,"children":1301},{"style":332},[1302],{"type":55,"value":1162},{"type":50,"tag":313,"props":1304,"children":1305},{"style":363},[1306],{"type":55,"value":466},{"type":50,"tag":313,"props":1308,"children":1309},{"style":332},[1310],{"type":55,"value":471},{"type":50,"tag":313,"props":1312,"children":1314},{"class":315,"line":1313},27,[1315],{"type":50,"tag":313,"props":1316,"children":1317},{"style":332},[1318],{"type":55,"value":1178},{"type":50,"tag":313,"props":1320,"children":1322},{"class":315,"line":1321},28,[1323],{"type":50,"tag":313,"props":1324,"children":1325},{"emptyLinePlaceholder":478},[1326],{"type":55,"value":481},{"type":50,"tag":313,"props":1328,"children":1330},{"class":315,"line":1329},29,[1331,1336,1340,1345,1349],{"type":50,"tag":313,"props":1332,"children":1333},{"style":363},[1334],{"type":55,"value":1335},"          transformOutput",{"type":50,"tag":313,"props":1337,"children":1338},{"style":332},[1339],{"type":55,"value":968},{"type":50,"tag":313,"props":1341,"children":1342},{"style":971},[1343],{"type":55,"value":1344}," result",{"type":50,"tag":313,"props":1346,"children":1347},{"style":332},[1348],{"type":55,"value":988},{"type":50,"tag":313,"props":1350,"children":1351},{"style":332},[1352],{"type":55,"value":693},{"type":50,"tag":313,"props":1354,"children":1356},{"class":315,"line":1355},30,[1357],{"type":50,"tag":313,"props":1358,"children":1359},{"style":427},[1360],{"type":55,"value":1361},"            \u002F\u002F Log function output\n",{"type":50,"tag":313,"props":1363,"children":1365},{"class":315,"line":1364},31,[1366,1370,1374,1379,1383,1387,1392,1396,1400],{"type":50,"tag":313,"props":1367,"children":1368},{"style":326},[1369],{"type":55,"value":1028},{"type":50,"tag":313,"props":1371,"children":1372},{"style":332},[1373],{"type":55,"value":494},{"type":50,"tag":313,"props":1375,"children":1376},{"style":343},[1377],{"type":55,"value":1378},"debug",{"type":50,"tag":313,"props":1380,"children":1381},{"style":363},[1382],{"type":55,"value":351},{"type":50,"tag":313,"props":1384,"children":1385},{"style":332},[1386],{"type":55,"value":387},{"type":50,"tag":313,"props":1388,"children":1389},{"style":379},[1390],{"type":55,"value":1391},"Function output",{"type":50,"tag":313,"props":1393,"children":1394},{"style":332},[1395],{"type":55,"value":387},{"type":50,"tag":313,"props":1397,"children":1398},{"style":332},[1399],{"type":55,"value":424},{"type":50,"tag":313,"props":1401,"children":1402},{"style":332},[1403],{"type":55,"value":693},{"type":50,"tag":313,"props":1405,"children":1407},{"class":315,"line":1406},32,[1408,1412,1416,1420,1424,1428],{"type":50,"tag":313,"props":1409,"children":1410},{"style":363},[1411],{"type":55,"value":1070},{"type":50,"tag":313,"props":1413,"children":1414},{"style":332},[1415],{"type":55,"value":371},{"type":50,"tag":313,"props":1417,"children":1418},{"style":326},[1419],{"type":55,"value":983},{"type":50,"tag":313,"props":1421,"children":1422},{"style":332},[1423],{"type":55,"value":494},{"type":50,"tag":313,"props":1425,"children":1426},{"style":326},[1427],{"type":55,"value":1087},{"type":50,"tag":313,"props":1429,"children":1430},{"style":332},[1431],{"type":55,"value":392},{"type":50,"tag":313,"props":1433,"children":1435},{"class":315,"line":1434},33,[1436,1441,1445,1449,1453],{"type":50,"tag":313,"props":1437,"children":1438},{"style":363},[1439],{"type":55,"value":1440},"              output",{"type":50,"tag":313,"props":1442,"children":1443},{"style":332},[1444],{"type":55,"value":371},{"type":50,"tag":313,"props":1446,"children":1447},{"style":326},[1448],{"type":55,"value":1344},{"type":50,"tag":313,"props":1450,"children":1451},{"style":332},[1452],{"type":55,"value":494},{"type":50,"tag":313,"props":1454,"children":1455},{"style":326},[1456],{"type":55,"value":1457},"data\n",{"type":50,"tag":313,"props":1459,"children":1461},{"class":315,"line":1460},34,[1462,1466,1470],{"type":50,"tag":313,"props":1463,"children":1464},{"style":332},[1465],{"type":55,"value":1162},{"type":50,"tag":313,"props":1467,"children":1468},{"style":363},[1469],{"type":55,"value":466},{"type":50,"tag":313,"props":1471,"children":1472},{"style":332},[1473],{"type":55,"value":471},{"type":50,"tag":313,"props":1475,"children":1477},{"class":315,"line":1476},35,[1478],{"type":50,"tag":313,"props":1479,"children":1480},{"emptyLinePlaceholder":478},[1481],{"type":55,"value":481},{"type":50,"tag":313,"props":1483,"children":1485},{"class":315,"line":1484},36,[1486],{"type":50,"tag":313,"props":1487,"children":1488},{"style":427},[1489],{"type":55,"value":1490},"            \u002F\u002F Return unmodified result\n",{"type":50,"tag":313,"props":1492,"children":1494},{"class":315,"line":1493},37,[1495,1500,1504,1508],{"type":50,"tag":313,"props":1496,"children":1497},{"style":758},[1498],{"type":55,"value":1499},"            return",{"type":50,"tag":313,"props":1501,"children":1502},{"style":332},[1503],{"type":55,"value":766},{"type":50,"tag":313,"props":1505,"children":1506},{"style":326},[1507],{"type":55,"value":1344},{"type":50,"tag":313,"props":1509,"children":1510},{"style":332},[1511],{"type":55,"value":1512}," };\n",{"type":50,"tag":313,"props":1514,"children":1516},{"class":315,"line":1515},38,[1517],{"type":50,"tag":313,"props":1518,"children":1519},{"style":332},[1520],{"type":55,"value":1521},"          }\n",{"type":50,"tag":313,"props":1523,"children":1525},{"class":315,"line":1524},39,[1526],{"type":50,"tag":313,"props":1527,"children":1528},{"style":332},[1529],{"type":55,"value":1530},"        };\n",{"type":50,"tag":313,"props":1532,"children":1534},{"class":315,"line":1533},40,[1535],{"type":50,"tag":313,"props":1536,"children":1537},{"style":332},[1538],{"type":55,"value":1539},"      },\n",{"type":50,"tag":313,"props":1541,"children":1543},{"class":315,"line":1542},41,[1544],{"type":50,"tag":313,"props":1545,"children":1546},{"emptyLinePlaceholder":478},[1547],{"type":55,"value":481},{"type":50,"tag":313,"props":1549,"children":1551},{"class":315,"line":1550},42,[1552],{"type":50,"tag":313,"props":1553,"children":1554},{"style":427},[1555],{"type":55,"value":1556},"      \u002F\u002F Event sending lifecycle\n",{"type":50,"tag":313,"props":1558,"children":1560},{"class":315,"line":1559},43,[1561,1566,1570],{"type":50,"tag":313,"props":1562,"children":1563},{"style":363},[1564],{"type":55,"value":1565},"      onSendEvent",{"type":50,"tag":313,"props":1567,"children":1568},{"style":332},[1569],{"type":55,"value":877},{"type":50,"tag":313,"props":1571,"children":1572},{"style":332},[1573],{"type":55,"value":693},{"type":50,"tag":313,"props":1575,"children":1577},{"class":315,"line":1576},44,[1578,1582],{"type":50,"tag":313,"props":1579,"children":1580},{"style":758},[1581],{"type":55,"value":1000},{"type":50,"tag":313,"props":1583,"children":1584},{"style":332},[1585],{"type":55,"value":693},{"type":50,"tag":313,"props":1587,"children":1589},{"class":315,"line":1588},45,[1590,1595,1599,1604,1608],{"type":50,"tag":313,"props":1591,"children":1592},{"style":363},[1593],{"type":55,"value":1594},"          transformInput",{"type":50,"tag":313,"props":1596,"children":1597},{"style":332},[1598],{"type":55,"value":968},{"type":50,"tag":313,"props":1600,"children":1601},{"style":971},[1602],{"type":55,"value":1603}," payloads",{"type":50,"tag":313,"props":1605,"children":1606},{"style":332},[1607],{"type":55,"value":988},{"type":50,"tag":313,"props":1609,"children":1610},{"style":332},[1611],{"type":55,"value":693},{"type":50,"tag":313,"props":1613,"children":1615},{"class":315,"line":1614},46,[1616,1620,1624,1628,1632,1636,1641,1645,1649],{"type":50,"tag":313,"props":1617,"children":1618},{"style":326},[1619],{"type":55,"value":1028},{"type":50,"tag":313,"props":1621,"children":1622},{"style":332},[1623],{"type":55,"value":494},{"type":50,"tag":313,"props":1625,"children":1626},{"style":343},[1627],{"type":55,"value":1037},{"type":50,"tag":313,"props":1629,"children":1630},{"style":363},[1631],{"type":55,"value":351},{"type":50,"tag":313,"props":1633,"children":1634},{"style":332},[1635],{"type":55,"value":387},{"type":50,"tag":313,"props":1637,"children":1638},{"style":379},[1639],{"type":55,"value":1640},"Sending events",{"type":50,"tag":313,"props":1642,"children":1643},{"style":332},[1644],{"type":55,"value":387},{"type":50,"tag":313,"props":1646,"children":1647},{"style":332},[1648],{"type":55,"value":424},{"type":50,"tag":313,"props":1650,"children":1651},{"style":332},[1652],{"type":55,"value":693},{"type":50,"tag":313,"props":1654,"children":1656},{"class":315,"line":1655},47,[1657,1662,1666,1670,1674,1679],{"type":50,"tag":313,"props":1658,"children":1659},{"style":363},[1660],{"type":55,"value":1661},"              count",{"type":50,"tag":313,"props":1663,"children":1664},{"style":332},[1665],{"type":55,"value":371},{"type":50,"tag":313,"props":1667,"children":1668},{"style":326},[1669],{"type":55,"value":1603},{"type":50,"tag":313,"props":1671,"children":1672},{"style":332},[1673],{"type":55,"value":494},{"type":50,"tag":313,"props":1675,"children":1676},{"style":326},[1677],{"type":55,"value":1678},"length",{"type":50,"tag":313,"props":1680,"children":1681},{"style":332},[1682],{"type":55,"value":392},{"type":50,"tag":313,"props":1684,"children":1686},{"class":315,"line":1685},48,[1687,1692,1696,1700,1704,1709,1713,1717,1721,1725,1729,1734,1738,1742],{"type":50,"tag":313,"props":1688,"children":1689},{"style":363},[1690],{"type":55,"value":1691},"              events",{"type":50,"tag":313,"props":1693,"children":1694},{"style":332},[1695],{"type":55,"value":371},{"type":50,"tag":313,"props":1697,"children":1698},{"style":326},[1699],{"type":55,"value":1603},{"type":50,"tag":313,"props":1701,"children":1702},{"style":332},[1703],{"type":55,"value":494},{"type":50,"tag":313,"props":1705,"children":1706},{"style":343},[1707],{"type":55,"value":1708},"map",{"type":50,"tag":313,"props":1710,"children":1711},{"style":363},[1712],{"type":55,"value":351},{"type":50,"tag":313,"props":1714,"children":1715},{"style":332},[1716],{"type":55,"value":351},{"type":50,"tag":313,"props":1718,"children":1719},{"style":971},[1720],{"type":55,"value":58},{"type":50,"tag":313,"props":1722,"children":1723},{"style":332},[1724],{"type":55,"value":466},{"type":50,"tag":313,"props":1726,"children":1727},{"style":320},[1728],{"type":55,"value":688},{"type":50,"tag":313,"props":1730,"children":1731},{"style":326},[1732],{"type":55,"value":1733}," p",{"type":50,"tag":313,"props":1735,"children":1736},{"style":332},[1737],{"type":55,"value":494},{"type":50,"tag":313,"props":1739,"children":1740},{"style":326},[1741],{"type":55,"value":1125},{"type":50,"tag":313,"props":1743,"children":1744},{"style":363},[1745],{"type":55,"value":1746},")\n",{"type":50,"tag":313,"props":1748,"children":1750},{"class":315,"line":1749},49,[1751,1755,1759],{"type":50,"tag":313,"props":1752,"children":1753},{"style":332},[1754],{"type":55,"value":1162},{"type":50,"tag":313,"props":1756,"children":1757},{"style":363},[1758],{"type":55,"value":466},{"type":50,"tag":313,"props":1760,"children":1761},{"style":332},[1762],{"type":55,"value":471},{"type":50,"tag":313,"props":1764,"children":1766},{"class":315,"line":1765},50,[1767],{"type":50,"tag":313,"props":1768,"children":1769},{"emptyLinePlaceholder":478},[1770],{"type":55,"value":481},{"type":50,"tag":313,"props":1772,"children":1774},{"class":315,"line":1773},51,[1775],{"type":50,"tag":313,"props":1776,"children":1777},{"style":427},[1778],{"type":55,"value":1779},"            \u002F\u002F Spread to convert readonly array to mutable array\n",{"type":50,"tag":313,"props":1781,"children":1783},{"class":315,"line":1782},52,[1784,1788,1792,1796,1800,1804,1809,1814,1819],{"type":50,"tag":313,"props":1785,"children":1786},{"style":758},[1787],{"type":55,"value":1499},{"type":50,"tag":313,"props":1789,"children":1790},{"style":332},[1791],{"type":55,"value":766},{"type":50,"tag":313,"props":1793,"children":1794},{"style":363},[1795],{"type":55,"value":1603},{"type":50,"tag":313,"props":1797,"children":1798},{"style":332},[1799],{"type":55,"value":371},{"type":50,"tag":313,"props":1801,"children":1802},{"style":363},[1803],{"type":55,"value":623},{"type":50,"tag":313,"props":1805,"children":1806},{"style":332},[1807],{"type":55,"value":1808},"...",{"type":50,"tag":313,"props":1810,"children":1811},{"style":326},[1812],{"type":55,"value":1813},"payloads",{"type":50,"tag":313,"props":1815,"children":1816},{"style":363},[1817],{"type":55,"value":1818},"] ",{"type":50,"tag":313,"props":1820,"children":1821},{"style":332},[1822],{"type":55,"value":1823},"};\n",{"type":50,"tag":313,"props":1825,"children":1827},{"class":315,"line":1826},53,[1828],{"type":50,"tag":313,"props":1829,"children":1830},{"style":332},[1831],{"type":55,"value":1521},{"type":50,"tag":313,"props":1833,"children":1835},{"class":315,"line":1834},54,[1836],{"type":50,"tag":313,"props":1837,"children":1838},{"style":332},[1839],{"type":55,"value":1530},{"type":50,"tag":313,"props":1841,"children":1843},{"class":315,"line":1842},55,[1844],{"type":50,"tag":313,"props":1845,"children":1846},{"style":332},[1847],{"type":55,"value":1848},"      }\n",{"type":50,"tag":313,"props":1850,"children":1852},{"class":315,"line":1851},56,[1853],{"type":50,"tag":313,"props":1854,"children":1855},{"style":332},[1856],{"type":55,"value":1857},"    };\n",{"type":50,"tag":313,"props":1859,"children":1861},{"class":315,"line":1860},57,[1862],{"type":50,"tag":313,"props":1863,"children":1864},{"style":332},[1865],{"type":55,"value":711},{"type":50,"tag":313,"props":1867,"children":1869},{"class":315,"line":1868},58,[1870,1874,1878],{"type":50,"tag":313,"props":1871,"children":1872},{"style":332},[1873],{"type":55,"value":461},{"type":50,"tag":313,"props":1875,"children":1876},{"style":326},[1877],{"type":55,"value":466},{"type":50,"tag":313,"props":1879,"children":1880},{"style":332},[1881],{"type":55,"value":471},{"type":50,"tag":295,"props":1883,"children":1885},{"id":1884},"python-implementation",[1886],{"type":55,"value":1887},"Python Implementation",{"type":50,"tag":58,"props":1889,"children":1890},{},[1891,1893,1899],{"type":55,"value":1892},"Python middleware follows a similar pattern. See ",{"type":50,"tag":79,"props":1894,"children":1896},{"href":1895},".\u002Freferences\u002Fdependency-injection.md",[1897],{"type":55,"value":1898},"Dependency Injection Reference",{"type":55,"value":1900}," for complete Python examples.",{"type":50,"tag":302,"props":1902,"children":1906},{"className":1903,"code":1905,"language":55},[1904],"language-text","\n## Dependency Injection\n\nShare expensive or stateful clients across all functions. **See [Dependency Injection Reference](.\u002Freferences\u002Fdependency-injection.md) for detailed patterns.**\n\n### Quick Example - Built-in DI\n\n```typescript\nimport { dependencyInjectionMiddleware } from \"inngest\";\n\nconst inngest = new Inngest({\n  id: 'my-app',\n  middleware: [\n    dependencyInjectionMiddleware({\n      openai: new OpenAI(),\n      db: new PrismaClient(),\n    }),\n  ],\n});\n\n\u002F\u002F Functions automatically get injected dependencies\ninngest.createFunction(\n  { id: \"ai-summary\", triggers: [{ event: \"document\u002Fuploaded\" }] },\n  async ({ event, openai, db }) => {\n    \u002F\u002F Dependencies available in function context\n    const summary = await openai.chat.completions.create({\n      messages: [{ role: \"user\", content: event.data.content }],\n      model: \"gpt-4\",\n    });\n\n    await db.document.update({\n      where: { id: event.data.documentId },\n      data: { summary: summary.choices[0].message.content }\n    });\n  }\n);\n",[1907],{"type":50,"tag":123,"props":1908,"children":1909},{"__ignoreMap":307},[1910],{"type":55,"value":1905},{"type":50,"tag":195,"props":1912,"children":1914},{"id":1913},"middleware-packages",[1915],{"type":55,"value":1916},"Middleware Packages",{"type":50,"tag":58,"props":1918,"children":1919},{},[1920,1922,1928,1930,1935,1937],{"type":55,"value":1921},"Beyond ",{"type":50,"tag":123,"props":1923,"children":1925},{"className":1924},[],[1926],{"type":55,"value":1927},"dependencyInjectionMiddleware",{"type":55,"value":1929}," (built-in, shown above), Inngest provides official middleware as ",{"type":50,"tag":71,"props":1931,"children":1932},{},[1933],{"type":55,"value":1934},"separate packages",{"type":55,"value":1936},". ",{"type":50,"tag":71,"props":1938,"children":1939},{},[1940,1942,1948],{"type":55,"value":1941},"See ",{"type":50,"tag":79,"props":1943,"children":1945},{"href":1944},".\u002Freferences\u002Fbuilt-in-middleware.md",[1946],{"type":55,"value":1947},"Middleware Reference",{"type":55,"value":1949}," for complete details.",{"type":50,"tag":295,"props":1951,"children":1953},{"id":1952},"encryption-middleware",[1954],{"type":55,"value":1955},"Encryption Middleware",{"type":50,"tag":302,"props":1957,"children":1961},{"className":1958,"code":1959,"language":1960,"meta":307,"style":307},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","npm install @inngest\u002Fmiddleware-encryption\n","bash",[1962],{"type":50,"tag":123,"props":1963,"children":1964},{"__ignoreMap":307},[1965],{"type":50,"tag":313,"props":1966,"children":1967},{"class":315,"line":316},[1968,1974,1979],{"type":50,"tag":313,"props":1969,"children":1971},{"style":1970},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[1972],{"type":55,"value":1973},"npm",{"type":50,"tag":313,"props":1975,"children":1976},{"style":379},[1977],{"type":55,"value":1978}," install",{"type":50,"tag":313,"props":1980,"children":1981},{"style":379},[1982],{"type":55,"value":1983}," @inngest\u002Fmiddleware-encryption\n",{"type":50,"tag":302,"props":1985,"children":1987},{"className":304,"code":1986,"language":306,"meta":307,"style":307},"import { encryptionMiddleware } from \"@inngest\u002Fmiddleware-encryption\";\n\nconst inngest = new Inngest({\n  id: \"my-app\",\n  middleware: [\n    encryptionMiddleware({\n      key: process.env.ENCRYPTION_KEY\n    })\n  ]\n});\n",[1988],{"type":50,"tag":123,"props":1989,"children":1990},{"__ignoreMap":307},[1991,2032,2039,2070,2097,2112,2128,2163,2175,2182],{"type":50,"tag":313,"props":1992,"children":1993},{"class":315,"line":316},[1994,1998,2002,2007,2011,2015,2019,2024,2028],{"type":50,"tag":313,"props":1995,"children":1996},{"style":758},[1997],{"type":55,"value":761},{"type":50,"tag":313,"props":1999,"children":2000},{"style":332},[2001],{"type":55,"value":766},{"type":50,"tag":313,"props":2003,"children":2004},{"style":326},[2005],{"type":55,"value":2006}," encryptionMiddleware",{"type":50,"tag":313,"props":2008,"children":2009},{"style":332},[2010],{"type":55,"value":655},{"type":50,"tag":313,"props":2012,"children":2013},{"style":758},[2014],{"type":55,"value":780},{"type":50,"tag":313,"props":2016,"children":2017},{"style":332},[2018],{"type":55,"value":376},{"type":50,"tag":313,"props":2020,"children":2021},{"style":379},[2022],{"type":55,"value":2023},"@inngest\u002Fmiddleware-encryption",{"type":50,"tag":313,"props":2025,"children":2026},{"style":332},[2027],{"type":55,"value":387},{"type":50,"tag":313,"props":2029,"children":2030},{"style":332},[2031],{"type":55,"value":471},{"type":50,"tag":313,"props":2033,"children":2034},{"class":315,"line":359},[2035],{"type":50,"tag":313,"props":2036,"children":2037},{"emptyLinePlaceholder":478},[2038],{"type":55,"value":481},{"type":50,"tag":313,"props":2040,"children":2041},{"class":315,"line":395},[2042,2046,2050,2054,2058,2062,2066],{"type":50,"tag":313,"props":2043,"children":2044},{"style":320},[2045],{"type":55,"value":323},{"type":50,"tag":313,"props":2047,"children":2048},{"style":326},[2049],{"type":55,"value":329},{"type":50,"tag":313,"props":2051,"children":2052},{"style":332},[2053],{"type":55,"value":335},{"type":50,"tag":313,"props":2055,"children":2056},{"style":332},[2057],{"type":55,"value":340},{"type":50,"tag":313,"props":2059,"children":2060},{"style":343},[2061],{"type":55,"value":346},{"type":50,"tag":313,"props":2063,"children":2064},{"style":326},[2065],{"type":55,"value":351},{"type":50,"tag":313,"props":2067,"children":2068},{"style":332},[2069],{"type":55,"value":356},{"type":50,"tag":313,"props":2071,"children":2072},{"class":315,"line":413},[2073,2077,2081,2085,2089,2093],{"type":50,"tag":313,"props":2074,"children":2075},{"style":363},[2076],{"type":55,"value":366},{"type":50,"tag":313,"props":2078,"children":2079},{"style":332},[2080],{"type":55,"value":371},{"type":50,"tag":313,"props":2082,"children":2083},{"style":332},[2084],{"type":55,"value":376},{"type":50,"tag":313,"props":2086,"children":2087},{"style":379},[2088],{"type":55,"value":382},{"type":50,"tag":313,"props":2090,"children":2091},{"style":332},[2092],{"type":55,"value":387},{"type":50,"tag":313,"props":2094,"children":2095},{"style":332},[2096],{"type":55,"value":392},{"type":50,"tag":313,"props":2098,"children":2099},{"class":315,"line":30},[2100,2104,2108],{"type":50,"tag":313,"props":2101,"children":2102},{"style":363},[2103],{"type":55,"value":401},{"type":50,"tag":313,"props":2105,"children":2106},{"style":332},[2107],{"type":55,"value":371},{"type":50,"tag":313,"props":2109,"children":2110},{"style":326},[2111],{"type":55,"value":410},{"type":50,"tag":313,"props":2113,"children":2114},{"class":315,"line":446},[2115,2120,2124],{"type":50,"tag":313,"props":2116,"children":2117},{"style":343},[2118],{"type":55,"value":2119},"    encryptionMiddleware",{"type":50,"tag":313,"props":2121,"children":2122},{"style":326},[2123],{"type":55,"value":351},{"type":50,"tag":313,"props":2125,"children":2126},{"style":332},[2127],{"type":55,"value":356},{"type":50,"tag":313,"props":2129,"children":2130},{"class":315,"line":455},[2131,2136,2140,2145,2149,2154,2158],{"type":50,"tag":313,"props":2132,"children":2133},{"style":363},[2134],{"type":55,"value":2135},"      key",{"type":50,"tag":313,"props":2137,"children":2138},{"style":332},[2139],{"type":55,"value":371},{"type":50,"tag":313,"props":2141,"children":2142},{"style":326},[2143],{"type":55,"value":2144}," process",{"type":50,"tag":313,"props":2146,"children":2147},{"style":332},[2148],{"type":55,"value":494},{"type":50,"tag":313,"props":2150,"children":2151},{"style":326},[2152],{"type":55,"value":2153},"env",{"type":50,"tag":313,"props":2155,"children":2156},{"style":332},[2157],{"type":55,"value":494},{"type":50,"tag":313,"props":2159,"children":2160},{"style":326},[2161],{"type":55,"value":2162},"ENCRYPTION_KEY\n",{"type":50,"tag":313,"props":2164,"children":2165},{"class":315,"line":474},[2166,2171],{"type":50,"tag":313,"props":2167,"children":2168},{"style":332},[2169],{"type":55,"value":2170},"    }",{"type":50,"tag":313,"props":2172,"children":2173},{"style":326},[2174],{"type":55,"value":1746},{"type":50,"tag":313,"props":2176,"children":2177},{"class":315,"line":484},[2178],{"type":50,"tag":313,"props":2179,"children":2180},{"style":326},[2181],{"type":55,"value":452},{"type":50,"tag":313,"props":2183,"children":2184},{"class":315,"line":507},[2185,2189,2193],{"type":50,"tag":313,"props":2186,"children":2187},{"style":332},[2188],{"type":55,"value":461},{"type":50,"tag":313,"props":2190,"children":2191},{"style":326},[2192],{"type":55,"value":466},{"type":50,"tag":313,"props":2194,"children":2195},{"style":332},[2196],{"type":55,"value":471},{"type":50,"tag":58,"props":2198,"children":2199},{},[2200,2202,2208,2210,2216],{"type":55,"value":2201},"Automatically encrypts all step data, function output, and event ",{"type":50,"tag":123,"props":2203,"children":2205},{"className":2204},[],[2206],{"type":55,"value":2207},"data.encrypted",{"type":55,"value":2209}," field. Supports key rotation via ",{"type":50,"tag":123,"props":2211,"children":2213},{"className":2212},[],[2214],{"type":55,"value":2215},"fallbackDecryptionKeys",{"type":55,"value":494},{"type":50,"tag":295,"props":2218,"children":2220},{"id":2219},"sentry-error-tracking",[2221],{"type":55,"value":2222},"Sentry Error Tracking",{"type":50,"tag":302,"props":2224,"children":2226},{"className":1958,"code":2225,"language":1960,"meta":307,"style":307},"npm install @inngest\u002Fmiddleware-sentry\n",[2227],{"type":50,"tag":123,"props":2228,"children":2229},{"__ignoreMap":307},[2230],{"type":50,"tag":313,"props":2231,"children":2232},{"class":315,"line":316},[2233,2237,2241],{"type":50,"tag":313,"props":2234,"children":2235},{"style":1970},[2236],{"type":55,"value":1973},{"type":50,"tag":313,"props":2238,"children":2239},{"style":379},[2240],{"type":55,"value":1978},{"type":50,"tag":313,"props":2242,"children":2243},{"style":379},[2244],{"type":55,"value":2245}," @inngest\u002Fmiddleware-sentry\n",{"type":50,"tag":302,"props":2247,"children":2249},{"className":304,"code":2248,"language":306,"meta":307,"style":307},"import * as Sentry from \"@sentry\u002Fnode\";\nimport { sentryMiddleware } from \"@inngest\u002Fmiddleware-sentry\";\n\nSentry.init({\n  \u002F* your Sentry config *\u002F\n});\n\nconst inngest = new Inngest({\n  id: \"my-app\",\n  middleware: [sentryMiddleware()]\n});\n",[2250],{"type":50,"tag":123,"props":2251,"children":2252},{"__ignoreMap":307},[2253,2297,2338,2345,2369,2377,2392,2399,2430,2457,2482],{"type":50,"tag":313,"props":2254,"children":2255},{"class":315,"line":316},[2256,2260,2265,2270,2275,2280,2284,2289,2293],{"type":50,"tag":313,"props":2257,"children":2258},{"style":758},[2259],{"type":55,"value":761},{"type":50,"tag":313,"props":2261,"children":2262},{"style":332},[2263],{"type":55,"value":2264}," *",{"type":50,"tag":313,"props":2266,"children":2267},{"style":758},[2268],{"type":55,"value":2269}," as",{"type":50,"tag":313,"props":2271,"children":2272},{"style":326},[2273],{"type":55,"value":2274}," Sentry ",{"type":50,"tag":313,"props":2276,"children":2277},{"style":758},[2278],{"type":55,"value":2279},"from",{"type":50,"tag":313,"props":2281,"children":2282},{"style":332},[2283],{"type":55,"value":376},{"type":50,"tag":313,"props":2285,"children":2286},{"style":379},[2287],{"type":55,"value":2288},"@sentry\u002Fnode",{"type":50,"tag":313,"props":2290,"children":2291},{"style":332},[2292],{"type":55,"value":387},{"type":50,"tag":313,"props":2294,"children":2295},{"style":332},[2296],{"type":55,"value":471},{"type":50,"tag":313,"props":2298,"children":2299},{"class":315,"line":359},[2300,2304,2308,2313,2317,2321,2325,2330,2334],{"type":50,"tag":313,"props":2301,"children":2302},{"style":758},[2303],{"type":55,"value":761},{"type":50,"tag":313,"props":2305,"children":2306},{"style":332},[2307],{"type":55,"value":766},{"type":50,"tag":313,"props":2309,"children":2310},{"style":326},[2311],{"type":55,"value":2312}," sentryMiddleware",{"type":50,"tag":313,"props":2314,"children":2315},{"style":332},[2316],{"type":55,"value":655},{"type":50,"tag":313,"props":2318,"children":2319},{"style":758},[2320],{"type":55,"value":780},{"type":50,"tag":313,"props":2322,"children":2323},{"style":332},[2324],{"type":55,"value":376},{"type":50,"tag":313,"props":2326,"children":2327},{"style":379},[2328],{"type":55,"value":2329},"@inngest\u002Fmiddleware-sentry",{"type":50,"tag":313,"props":2331,"children":2332},{"style":332},[2333],{"type":55,"value":387},{"type":50,"tag":313,"props":2335,"children":2336},{"style":332},[2337],{"type":55,"value":471},{"type":50,"tag":313,"props":2339,"children":2340},{"class":315,"line":395},[2341],{"type":50,"tag":313,"props":2342,"children":2343},{"emptyLinePlaceholder":478},[2344],{"type":55,"value":481},{"type":50,"tag":313,"props":2346,"children":2347},{"class":315,"line":413},[2348,2352,2356,2361,2365],{"type":50,"tag":313,"props":2349,"children":2350},{"style":326},[2351],{"type":55,"value":24},{"type":50,"tag":313,"props":2353,"children":2354},{"style":332},[2355],{"type":55,"value":494},{"type":50,"tag":313,"props":2357,"children":2358},{"style":343},[2359],{"type":55,"value":2360},"init",{"type":50,"tag":313,"props":2362,"children":2363},{"style":326},[2364],{"type":55,"value":351},{"type":50,"tag":313,"props":2366,"children":2367},{"style":332},[2368],{"type":55,"value":356},{"type":50,"tag":313,"props":2370,"children":2371},{"class":315,"line":30},[2372],{"type":50,"tag":313,"props":2373,"children":2374},{"style":427},[2375],{"type":55,"value":2376},"  \u002F* your Sentry config *\u002F\n",{"type":50,"tag":313,"props":2378,"children":2379},{"class":315,"line":446},[2380,2384,2388],{"type":50,"tag":313,"props":2381,"children":2382},{"style":332},[2383],{"type":55,"value":461},{"type":50,"tag":313,"props":2385,"children":2386},{"style":326},[2387],{"type":55,"value":466},{"type":50,"tag":313,"props":2389,"children":2390},{"style":332},[2391],{"type":55,"value":471},{"type":50,"tag":313,"props":2393,"children":2394},{"class":315,"line":455},[2395],{"type":50,"tag":313,"props":2396,"children":2397},{"emptyLinePlaceholder":478},[2398],{"type":55,"value":481},{"type":50,"tag":313,"props":2400,"children":2401},{"class":315,"line":474},[2402,2406,2410,2414,2418,2422,2426],{"type":50,"tag":313,"props":2403,"children":2404},{"style":320},[2405],{"type":55,"value":323},{"type":50,"tag":313,"props":2407,"children":2408},{"style":326},[2409],{"type":55,"value":329},{"type":50,"tag":313,"props":2411,"children":2412},{"style":332},[2413],{"type":55,"value":335},{"type":50,"tag":313,"props":2415,"children":2416},{"style":332},[2417],{"type":55,"value":340},{"type":50,"tag":313,"props":2419,"children":2420},{"style":343},[2421],{"type":55,"value":346},{"type":50,"tag":313,"props":2423,"children":2424},{"style":326},[2425],{"type":55,"value":351},{"type":50,"tag":313,"props":2427,"children":2428},{"style":332},[2429],{"type":55,"value":356},{"type":50,"tag":313,"props":2431,"children":2432},{"class":315,"line":484},[2433,2437,2441,2445,2449,2453],{"type":50,"tag":313,"props":2434,"children":2435},{"style":363},[2436],{"type":55,"value":366},{"type":50,"tag":313,"props":2438,"children":2439},{"style":332},[2440],{"type":55,"value":371},{"type":50,"tag":313,"props":2442,"children":2443},{"style":332},[2444],{"type":55,"value":376},{"type":50,"tag":313,"props":2446,"children":2447},{"style":379},[2448],{"type":55,"value":382},{"type":50,"tag":313,"props":2450,"children":2451},{"style":332},[2452],{"type":55,"value":387},{"type":50,"tag":313,"props":2454,"children":2455},{"style":332},[2456],{"type":55,"value":392},{"type":50,"tag":313,"props":2458,"children":2459},{"class":315,"line":507},[2460,2464,2468,2472,2477],{"type":50,"tag":313,"props":2461,"children":2462},{"style":363},[2463],{"type":55,"value":401},{"type":50,"tag":313,"props":2465,"children":2466},{"style":332},[2467],{"type":55,"value":371},{"type":50,"tag":313,"props":2469,"children":2470},{"style":326},[2471],{"type":55,"value":623},{"type":50,"tag":313,"props":2473,"children":2474},{"style":343},[2475],{"type":55,"value":2476},"sentryMiddleware",{"type":50,"tag":313,"props":2478,"children":2479},{"style":326},[2480],{"type":55,"value":2481},"()]\n",{"type":50,"tag":313,"props":2483,"children":2484},{"class":315,"line":516},[2485,2489,2493],{"type":50,"tag":313,"props":2486,"children":2487},{"style":332},[2488],{"type":55,"value":461},{"type":50,"tag":313,"props":2490,"children":2491},{"style":326},[2492],{"type":55,"value":466},{"type":50,"tag":313,"props":2494,"children":2495},{"style":332},[2496],{"type":55,"value":471},{"type":50,"tag":58,"props":2498,"children":2499},{},[2500,2502,2508],{"type":55,"value":2501},"Captures exceptions, adds tracing to each function run, and includes function ID and event names as context. Requires ",{"type":50,"tag":123,"props":2503,"children":2505},{"className":2504},[],[2506],{"type":55,"value":2507},"@sentry\u002F*@>=8.0.0",{"type":55,"value":494},{"type":50,"tag":195,"props":2510,"children":2512},{"id":2511},"common-middleware-patterns",[2513],{"type":55,"value":2514},"Common Middleware Patterns",{"type":50,"tag":295,"props":2516,"children":2518},{"id":2517},"metrics-and-performance-tracking",[2519],{"type":55,"value":2520},"Metrics and Performance Tracking",{"type":50,"tag":302,"props":2522,"children":2524},{"className":304,"code":2523,"language":306,"meta":307,"style":307},"const metricsMiddleware = new InngestMiddleware({\n  name: \"Metrics Tracking\",\n  init() {\n    return {\n      onFunctionRun({ ctx, fn }) {\n        let startTime: number;\n\n        return {\n          beforeExecution() {\n            startTime = Date.now();\n            metrics.increment(\"inngest.step.started\", {\n              function: fn.id,\n              event: ctx.event.name\n            });\n          },\n\n          afterExecution() {\n            const duration = Date.now() - startTime;\n            metrics.histogram(\"inngest.step.duration\", duration, {\n              function: fn.id,\n              event: ctx.event.name\n            });\n          },\n\n          transformOutput({ result }) {\n            const status = result.error ? \"error\" : \"success\";\n            metrics.increment(\"inngest.step.completed\", {\n              function: fn.id,\n              status: status\n            });\n\n            return { result };\n          }\n        };\n      }\n    };\n  }\n});\n",[2525],{"type":50,"tag":123,"props":2526,"children":2527},{"__ignoreMap":307},[2528,2560,2588,2603,2614,2645,2671,2678,2689,2704,2738,2780,2808,2841,2856,2863,2870,2885,2932,2981,3008,3039,3054,3061,3068,3091,3159,3199,3226,3243,3258,3265,3284,3291,3298,3305,3312,3319],{"type":50,"tag":313,"props":2529,"children":2530},{"class":315,"line":316},[2531,2535,2540,2544,2548,2552,2556],{"type":50,"tag":313,"props":2532,"children":2533},{"style":320},[2534],{"type":55,"value":323},{"type":50,"tag":313,"props":2536,"children":2537},{"style":326},[2538],{"type":55,"value":2539}," metricsMiddleware ",{"type":50,"tag":313,"props":2541,"children":2542},{"style":332},[2543],{"type":55,"value":335},{"type":50,"tag":313,"props":2545,"children":2546},{"style":332},[2547],{"type":55,"value":340},{"type":50,"tag":313,"props":2549,"children":2550},{"style":343},[2551],{"type":55,"value":771},{"type":50,"tag":313,"props":2553,"children":2554},{"style":326},[2555],{"type":55,"value":351},{"type":50,"tag":313,"props":2557,"children":2558},{"style":332},[2559],{"type":55,"value":356},{"type":50,"tag":313,"props":2561,"children":2562},{"class":315,"line":359},[2563,2567,2571,2575,2580,2584],{"type":50,"tag":313,"props":2564,"children":2565},{"style":363},[2566],{"type":55,"value":843},{"type":50,"tag":313,"props":2568,"children":2569},{"style":332},[2570],{"type":55,"value":371},{"type":50,"tag":313,"props":2572,"children":2573},{"style":332},[2574],{"type":55,"value":376},{"type":50,"tag":313,"props":2576,"children":2577},{"style":379},[2578],{"type":55,"value":2579},"Metrics Tracking",{"type":50,"tag":313,"props":2581,"children":2582},{"style":332},[2583],{"type":55,"value":387},{"type":50,"tag":313,"props":2585,"children":2586},{"style":332},[2587],{"type":55,"value":392},{"type":50,"tag":313,"props":2589,"children":2590},{"class":315,"line":395},[2591,2595,2599],{"type":50,"tag":313,"props":2592,"children":2593},{"style":363},[2594],{"type":55,"value":872},{"type":50,"tag":313,"props":2596,"children":2597},{"style":332},[2598],{"type":55,"value":877},{"type":50,"tag":313,"props":2600,"children":2601},{"style":332},[2602],{"type":55,"value":693},{"type":50,"tag":313,"props":2604,"children":2605},{"class":315,"line":413},[2606,2610],{"type":50,"tag":313,"props":2607,"children":2608},{"style":758},[2609],{"type":55,"value":935},{"type":50,"tag":313,"props":2611,"children":2612},{"style":332},[2613],{"type":55,"value":693},{"type":50,"tag":313,"props":2615,"children":2616},{"class":315,"line":30},[2617,2621,2625,2629,2633,2637,2641],{"type":50,"tag":313,"props":2618,"children":2619},{"style":363},[2620],{"type":55,"value":963},{"type":50,"tag":313,"props":2622,"children":2623},{"style":332},[2624],{"type":55,"value":968},{"type":50,"tag":313,"props":2626,"children":2627},{"style":971},[2628],{"type":55,"value":974},{"type":50,"tag":313,"props":2630,"children":2631},{"style":332},[2632],{"type":55,"value":424},{"type":50,"tag":313,"props":2634,"children":2635},{"style":971},[2636],{"type":55,"value":983},{"type":50,"tag":313,"props":2638,"children":2639},{"style":332},[2640],{"type":55,"value":988},{"type":50,"tag":313,"props":2642,"children":2643},{"style":332},[2644],{"type":55,"value":693},{"type":50,"tag":313,"props":2646,"children":2647},{"class":315,"line":446},[2648,2653,2658,2662,2667],{"type":50,"tag":313,"props":2649,"children":2650},{"style":320},[2651],{"type":55,"value":2652},"        let",{"type":50,"tag":313,"props":2654,"children":2655},{"style":326},[2656],{"type":55,"value":2657}," startTime",{"type":50,"tag":313,"props":2659,"children":2660},{"style":332},[2661],{"type":55,"value":371},{"type":50,"tag":313,"props":2663,"children":2664},{"style":1970},[2665],{"type":55,"value":2666}," number",{"type":50,"tag":313,"props":2668,"children":2669},{"style":332},[2670],{"type":55,"value":471},{"type":50,"tag":313,"props":2672,"children":2673},{"class":315,"line":455},[2674],{"type":50,"tag":313,"props":2675,"children":2676},{"emptyLinePlaceholder":478},[2677],{"type":55,"value":481},{"type":50,"tag":313,"props":2679,"children":2680},{"class":315,"line":474},[2681,2685],{"type":50,"tag":313,"props":2682,"children":2683},{"style":758},[2684],{"type":55,"value":1000},{"type":50,"tag":313,"props":2686,"children":2687},{"style":332},[2688],{"type":55,"value":693},{"type":50,"tag":313,"props":2690,"children":2691},{"class":315,"line":484},[2692,2696,2700],{"type":50,"tag":313,"props":2693,"children":2694},{"style":363},[2695],{"type":55,"value":1012},{"type":50,"tag":313,"props":2697,"children":2698},{"style":332},[2699],{"type":55,"value":877},{"type":50,"tag":313,"props":2701,"children":2702},{"style":332},[2703],{"type":55,"value":693},{"type":50,"tag":313,"props":2705,"children":2706},{"class":315,"line":507},[2707,2712,2716,2721,2725,2730,2734],{"type":50,"tag":313,"props":2708,"children":2709},{"style":326},[2710],{"type":55,"value":2711},"            startTime",{"type":50,"tag":313,"props":2713,"children":2714},{"style":332},[2715],{"type":55,"value":907},{"type":50,"tag":313,"props":2717,"children":2718},{"style":326},[2719],{"type":55,"value":2720}," Date",{"type":50,"tag":313,"props":2722,"children":2723},{"style":332},[2724],{"type":55,"value":494},{"type":50,"tag":313,"props":2726,"children":2727},{"style":343},[2728],{"type":55,"value":2729},"now",{"type":50,"tag":313,"props":2731,"children":2732},{"style":363},[2733],{"type":55,"value":877},{"type":50,"tag":313,"props":2735,"children":2736},{"style":332},[2737],{"type":55,"value":471},{"type":50,"tag":313,"props":2739,"children":2740},{"class":315,"line":516},[2741,2746,2750,2755,2759,2763,2768,2772,2776],{"type":50,"tag":313,"props":2742,"children":2743},{"style":326},[2744],{"type":55,"value":2745},"            metrics",{"type":50,"tag":313,"props":2747,"children":2748},{"style":332},[2749],{"type":55,"value":494},{"type":50,"tag":313,"props":2751,"children":2752},{"style":343},[2753],{"type":55,"value":2754},"increment",{"type":50,"tag":313,"props":2756,"children":2757},{"style":363},[2758],{"type":55,"value":351},{"type":50,"tag":313,"props":2760,"children":2761},{"style":332},[2762],{"type":55,"value":387},{"type":50,"tag":313,"props":2764,"children":2765},{"style":379},[2766],{"type":55,"value":2767},"inngest.step.started",{"type":50,"tag":313,"props":2769,"children":2770},{"style":332},[2771],{"type":55,"value":387},{"type":50,"tag":313,"props":2773,"children":2774},{"style":332},[2775],{"type":55,"value":424},{"type":50,"tag":313,"props":2777,"children":2778},{"style":332},[2779],{"type":55,"value":693},{"type":50,"tag":313,"props":2781,"children":2782},{"class":315,"line":546},[2783,2788,2792,2796,2800,2804],{"type":50,"tag":313,"props":2784,"children":2785},{"style":363},[2786],{"type":55,"value":2787},"              function",{"type":50,"tag":313,"props":2789,"children":2790},{"style":332},[2791],{"type":55,"value":371},{"type":50,"tag":313,"props":2793,"children":2794},{"style":326},[2795],{"type":55,"value":983},{"type":50,"tag":313,"props":2797,"children":2798},{"style":332},[2799],{"type":55,"value":494},{"type":50,"tag":313,"props":2801,"children":2802},{"style":326},[2803],{"type":55,"value":1087},{"type":50,"tag":313,"props":2805,"children":2806},{"style":332},[2807],{"type":55,"value":392},{"type":50,"tag":313,"props":2809,"children":2810},{"class":315,"line":563},[2811,2816,2820,2824,2828,2832,2836],{"type":50,"tag":313,"props":2812,"children":2813},{"style":363},[2814],{"type":55,"value":2815},"              event",{"type":50,"tag":313,"props":2817,"children":2818},{"style":332},[2819],{"type":55,"value":371},{"type":50,"tag":313,"props":2821,"children":2822},{"style":326},[2823],{"type":55,"value":974},{"type":50,"tag":313,"props":2825,"children":2826},{"style":332},[2827],{"type":55,"value":494},{"type":50,"tag":313,"props":2829,"children":2830},{"style":326},[2831],{"type":55,"value":1116},{"type":50,"tag":313,"props":2833,"children":2834},{"style":332},[2835],{"type":55,"value":494},{"type":50,"tag":313,"props":2837,"children":2838},{"style":326},[2839],{"type":55,"value":2840},"name\n",{"type":50,"tag":313,"props":2842,"children":2843},{"class":315,"line":581},[2844,2848,2852],{"type":50,"tag":313,"props":2845,"children":2846},{"style":332},[2847],{"type":55,"value":1162},{"type":50,"tag":313,"props":2849,"children":2850},{"style":363},[2851],{"type":55,"value":466},{"type":50,"tag":313,"props":2853,"children":2854},{"style":332},[2855],{"type":55,"value":471},{"type":50,"tag":313,"props":2857,"children":2858},{"class":315,"line":595},[2859],{"type":50,"tag":313,"props":2860,"children":2861},{"style":332},[2862],{"type":55,"value":1178},{"type":50,"tag":313,"props":2864,"children":2865},{"class":315,"line":608},[2866],{"type":50,"tag":313,"props":2867,"children":2868},{"emptyLinePlaceholder":478},[2869],{"type":55,"value":481},{"type":50,"tag":313,"props":2871,"children":2872},{"class":315,"line":663},[2873,2877,2881],{"type":50,"tag":313,"props":2874,"children":2875},{"style":363},[2876],{"type":55,"value":1194},{"type":50,"tag":313,"props":2878,"children":2879},{"style":332},[2880],{"type":55,"value":877},{"type":50,"tag":313,"props":2882,"children":2883},{"style":332},[2884],{"type":55,"value":693},{"type":50,"tag":313,"props":2886,"children":2887},{"class":315,"line":672},[2888,2893,2898,2902,2906,2910,2914,2919,2924,2928],{"type":50,"tag":313,"props":2889,"children":2890},{"style":320},[2891],{"type":55,"value":2892},"            const",{"type":50,"tag":313,"props":2894,"children":2895},{"style":326},[2896],{"type":55,"value":2897}," duration",{"type":50,"tag":313,"props":2899,"children":2900},{"style":332},[2901],{"type":55,"value":907},{"type":50,"tag":313,"props":2903,"children":2904},{"style":326},[2905],{"type":55,"value":2720},{"type":50,"tag":313,"props":2907,"children":2908},{"style":332},[2909],{"type":55,"value":494},{"type":50,"tag":313,"props":2911,"children":2912},{"style":343},[2913],{"type":55,"value":2729},{"type":50,"tag":313,"props":2915,"children":2916},{"style":363},[2917],{"type":55,"value":2918},"() ",{"type":50,"tag":313,"props":2920,"children":2921},{"style":332},[2922],{"type":55,"value":2923},"-",{"type":50,"tag":313,"props":2925,"children":2926},{"style":326},[2927],{"type":55,"value":2657},{"type":50,"tag":313,"props":2929,"children":2930},{"style":332},[2931],{"type":55,"value":471},{"type":50,"tag":313,"props":2933,"children":2934},{"class":315,"line":696},[2935,2939,2943,2948,2952,2956,2961,2965,2969,2973,2977],{"type":50,"tag":313,"props":2936,"children":2937},{"style":326},[2938],{"type":55,"value":2745},{"type":50,"tag":313,"props":2940,"children":2941},{"style":332},[2942],{"type":55,"value":494},{"type":50,"tag":313,"props":2944,"children":2945},{"style":343},[2946],{"type":55,"value":2947},"histogram",{"type":50,"tag":313,"props":2949,"children":2950},{"style":363},[2951],{"type":55,"value":351},{"type":50,"tag":313,"props":2953,"children":2954},{"style":332},[2955],{"type":55,"value":387},{"type":50,"tag":313,"props":2957,"children":2958},{"style":379},[2959],{"type":55,"value":2960},"inngest.step.duration",{"type":50,"tag":313,"props":2962,"children":2963},{"style":332},[2964],{"type":55,"value":387},{"type":50,"tag":313,"props":2966,"children":2967},{"style":332},[2968],{"type":55,"value":424},{"type":50,"tag":313,"props":2970,"children":2971},{"style":326},[2972],{"type":55,"value":2897},{"type":50,"tag":313,"props":2974,"children":2975},{"style":332},[2976],{"type":55,"value":424},{"type":50,"tag":313,"props":2978,"children":2979},{"style":332},[2980],{"type":55,"value":693},{"type":50,"tag":313,"props":2982,"children":2983},{"class":315,"line":705},[2984,2988,2992,2996,3000,3004],{"type":50,"tag":313,"props":2985,"children":2986},{"style":363},[2987],{"type":55,"value":2787},{"type":50,"tag":313,"props":2989,"children":2990},{"style":332},[2991],{"type":55,"value":371},{"type":50,"tag":313,"props":2993,"children":2994},{"style":326},[2995],{"type":55,"value":983},{"type":50,"tag":313,"props":2997,"children":2998},{"style":332},[2999],{"type":55,"value":494},{"type":50,"tag":313,"props":3001,"children":3002},{"style":326},[3003],{"type":55,"value":1087},{"type":50,"tag":313,"props":3005,"children":3006},{"style":332},[3007],{"type":55,"value":392},{"type":50,"tag":313,"props":3009,"children":3010},{"class":315,"line":714},[3011,3015,3019,3023,3027,3031,3035],{"type":50,"tag":313,"props":3012,"children":3013},{"style":363},[3014],{"type":55,"value":2815},{"type":50,"tag":313,"props":3016,"children":3017},{"style":332},[3018],{"type":55,"value":371},{"type":50,"tag":313,"props":3020,"children":3021},{"style":326},[3022],{"type":55,"value":974},{"type":50,"tag":313,"props":3024,"children":3025},{"style":332},[3026],{"type":55,"value":494},{"type":50,"tag":313,"props":3028,"children":3029},{"style":326},[3030],{"type":55,"value":1116},{"type":50,"tag":313,"props":3032,"children":3033},{"style":332},[3034],{"type":55,"value":494},{"type":50,"tag":313,"props":3036,"children":3037},{"style":326},[3038],{"type":55,"value":2840},{"type":50,"tag":313,"props":3040,"children":3041},{"class":315,"line":1188},[3042,3046,3050],{"type":50,"tag":313,"props":3043,"children":3044},{"style":332},[3045],{"type":55,"value":1162},{"type":50,"tag":313,"props":3047,"children":3048},{"style":363},[3049],{"type":55,"value":466},{"type":50,"tag":313,"props":3051,"children":3052},{"style":332},[3053],{"type":55,"value":471},{"type":50,"tag":313,"props":3055,"children":3056},{"class":315,"line":1205},[3057],{"type":50,"tag":313,"props":3058,"children":3059},{"style":332},[3060],{"type":55,"value":1178},{"type":50,"tag":313,"props":3062,"children":3063},{"class":315,"line":1246},[3064],{"type":50,"tag":313,"props":3065,"children":3066},{"emptyLinePlaceholder":478},[3067],{"type":55,"value":481},{"type":50,"tag":313,"props":3069,"children":3070},{"class":315,"line":1274},[3071,3075,3079,3083,3087],{"type":50,"tag":313,"props":3072,"children":3073},{"style":363},[3074],{"type":55,"value":1335},{"type":50,"tag":313,"props":3076,"children":3077},{"style":332},[3078],{"type":55,"value":968},{"type":50,"tag":313,"props":3080,"children":3081},{"style":971},[3082],{"type":55,"value":1344},{"type":50,"tag":313,"props":3084,"children":3085},{"style":332},[3086],{"type":55,"value":988},{"type":50,"tag":313,"props":3088,"children":3089},{"style":332},[3090],{"type":55,"value":693},{"type":50,"tag":313,"props":3092,"children":3093},{"class":315,"line":26},[3094,3098,3103,3107,3111,3115,3120,3125,3129,3133,3137,3142,3146,3151,3155],{"type":50,"tag":313,"props":3095,"children":3096},{"style":320},[3097],{"type":55,"value":2892},{"type":50,"tag":313,"props":3099,"children":3100},{"style":326},[3101],{"type":55,"value":3102}," status",{"type":50,"tag":313,"props":3104,"children":3105},{"style":332},[3106],{"type":55,"value":907},{"type":50,"tag":313,"props":3108,"children":3109},{"style":326},[3110],{"type":55,"value":1344},{"type":50,"tag":313,"props":3112,"children":3113},{"style":332},[3114],{"type":55,"value":494},{"type":50,"tag":313,"props":3116,"children":3117},{"style":326},[3118],{"type":55,"value":3119},"error",{"type":50,"tag":313,"props":3121,"children":3122},{"style":332},[3123],{"type":55,"value":3124}," ?",{"type":50,"tag":313,"props":3126,"children":3127},{"style":332},[3128],{"type":55,"value":376},{"type":50,"tag":313,"props":3130,"children":3131},{"style":379},[3132],{"type":55,"value":3119},{"type":50,"tag":313,"props":3134,"children":3135},{"style":332},[3136],{"type":55,"value":387},{"type":50,"tag":313,"props":3138,"children":3139},{"style":332},[3140],{"type":55,"value":3141}," :",{"type":50,"tag":313,"props":3143,"children":3144},{"style":332},[3145],{"type":55,"value":376},{"type":50,"tag":313,"props":3147,"children":3148},{"style":379},[3149],{"type":55,"value":3150},"success",{"type":50,"tag":313,"props":3152,"children":3153},{"style":332},[3154],{"type":55,"value":387},{"type":50,"tag":313,"props":3156,"children":3157},{"style":332},[3158],{"type":55,"value":471},{"type":50,"tag":313,"props":3160,"children":3161},{"class":315,"line":1313},[3162,3166,3170,3174,3178,3182,3187,3191,3195],{"type":50,"tag":313,"props":3163,"children":3164},{"style":326},[3165],{"type":55,"value":2745},{"type":50,"tag":313,"props":3167,"children":3168},{"style":332},[3169],{"type":55,"value":494},{"type":50,"tag":313,"props":3171,"children":3172},{"style":343},[3173],{"type":55,"value":2754},{"type":50,"tag":313,"props":3175,"children":3176},{"style":363},[3177],{"type":55,"value":351},{"type":50,"tag":313,"props":3179,"children":3180},{"style":332},[3181],{"type":55,"value":387},{"type":50,"tag":313,"props":3183,"children":3184},{"style":379},[3185],{"type":55,"value":3186},"inngest.step.completed",{"type":50,"tag":313,"props":3188,"children":3189},{"style":332},[3190],{"type":55,"value":387},{"type":50,"tag":313,"props":3192,"children":3193},{"style":332},[3194],{"type":55,"value":424},{"type":50,"tag":313,"props":3196,"children":3197},{"style":332},[3198],{"type":55,"value":693},{"type":50,"tag":313,"props":3200,"children":3201},{"class":315,"line":1321},[3202,3206,3210,3214,3218,3222],{"type":50,"tag":313,"props":3203,"children":3204},{"style":363},[3205],{"type":55,"value":2787},{"type":50,"tag":313,"props":3207,"children":3208},{"style":332},[3209],{"type":55,"value":371},{"type":50,"tag":313,"props":3211,"children":3212},{"style":326},[3213],{"type":55,"value":983},{"type":50,"tag":313,"props":3215,"children":3216},{"style":332},[3217],{"type":55,"value":494},{"type":50,"tag":313,"props":3219,"children":3220},{"style":326},[3221],{"type":55,"value":1087},{"type":50,"tag":313,"props":3223,"children":3224},{"style":332},[3225],{"type":55,"value":392},{"type":50,"tag":313,"props":3227,"children":3228},{"class":315,"line":1329},[3229,3234,3238],{"type":50,"tag":313,"props":3230,"children":3231},{"style":363},[3232],{"type":55,"value":3233},"              status",{"type":50,"tag":313,"props":3235,"children":3236},{"style":332},[3237],{"type":55,"value":371},{"type":50,"tag":313,"props":3239,"children":3240},{"style":326},[3241],{"type":55,"value":3242}," status\n",{"type":50,"tag":313,"props":3244,"children":3245},{"class":315,"line":1355},[3246,3250,3254],{"type":50,"tag":313,"props":3247,"children":3248},{"style":332},[3249],{"type":55,"value":1162},{"type":50,"tag":313,"props":3251,"children":3252},{"style":363},[3253],{"type":55,"value":466},{"type":50,"tag":313,"props":3255,"children":3256},{"style":332},[3257],{"type":55,"value":471},{"type":50,"tag":313,"props":3259,"children":3260},{"class":315,"line":1364},[3261],{"type":50,"tag":313,"props":3262,"children":3263},{"emptyLinePlaceholder":478},[3264],{"type":55,"value":481},{"type":50,"tag":313,"props":3266,"children":3267},{"class":315,"line":1406},[3268,3272,3276,3280],{"type":50,"tag":313,"props":3269,"children":3270},{"style":758},[3271],{"type":55,"value":1499},{"type":50,"tag":313,"props":3273,"children":3274},{"style":332},[3275],{"type":55,"value":766},{"type":50,"tag":313,"props":3277,"children":3278},{"style":326},[3279],{"type":55,"value":1344},{"type":50,"tag":313,"props":3281,"children":3282},{"style":332},[3283],{"type":55,"value":1512},{"type":50,"tag":313,"props":3285,"children":3286},{"class":315,"line":1434},[3287],{"type":50,"tag":313,"props":3288,"children":3289},{"style":332},[3290],{"type":55,"value":1521},{"type":50,"tag":313,"props":3292,"children":3293},{"class":315,"line":1460},[3294],{"type":50,"tag":313,"props":3295,"children":3296},{"style":332},[3297],{"type":55,"value":1530},{"type":50,"tag":313,"props":3299,"children":3300},{"class":315,"line":1476},[3301],{"type":50,"tag":313,"props":3302,"children":3303},{"style":332},[3304],{"type":55,"value":1848},{"type":50,"tag":313,"props":3306,"children":3307},{"class":315,"line":1484},[3308],{"type":50,"tag":313,"props":3309,"children":3310},{"style":332},[3311],{"type":55,"value":1857},{"type":50,"tag":313,"props":3313,"children":3314},{"class":315,"line":1493},[3315],{"type":50,"tag":313,"props":3316,"children":3317},{"style":332},[3318],{"type":55,"value":711},{"type":50,"tag":313,"props":3320,"children":3321},{"class":315,"line":1515},[3322,3326,3330],{"type":50,"tag":313,"props":3323,"children":3324},{"style":332},[3325],{"type":55,"value":461},{"type":50,"tag":313,"props":3327,"children":3328},{"style":326},[3329],{"type":55,"value":466},{"type":50,"tag":313,"props":3331,"children":3332},{"style":332},[3333],{"type":55,"value":471},{"type":50,"tag":295,"props":3335,"children":3337},{"id":3336},"advanced-patterns",[3338],{"type":55,"value":3339},"Advanced Patterns",{"type":50,"tag":58,"props":3341,"children":3342},{},[3343,3347,3349,3354,3356,3361],{"type":50,"tag":71,"props":3344,"children":3345},{},[3346],{"type":55,"value":266},{"type":55,"value":3348}," Validate tokens and inject user context\n",{"type":50,"tag":71,"props":3350,"children":3351},{},[3352],{"type":55,"value":3353},"Conditional logic:",{"type":55,"value":3355}," Apply middleware based on event type or function\n",{"type":50,"tag":71,"props":3357,"children":3358},{},[3359],{"type":55,"value":3360},"Circuit breakers:",{"type":55,"value":3362}," Prevent cascading failures from external services",{"type":50,"tag":295,"props":3364,"children":3366},{"id":3365},"configuration-based-middleware",[3367],{"type":55,"value":3368},"Configuration-Based Middleware",{"type":50,"tag":58,"props":3370,"children":3371},{},[3372],{"type":55,"value":3373},"Create reusable middleware with configuration options for different environments and use cases. See reference documentation for complete examples.",{"type":50,"tag":195,"props":3375,"children":3377},{"id":3376},"best-practices",[3378],{"type":55,"value":3379},"Best Practices",{"type":50,"tag":295,"props":3381,"children":3383},{"id":3382},"design-principles",[3384],{"type":55,"value":3385},"Design Principles",{"type":50,"tag":3387,"props":3388,"children":3389},"ol",{},[3390,3400,3410,3420,3430],{"type":50,"tag":219,"props":3391,"children":3392},{},[3393,3398],{"type":50,"tag":71,"props":3394,"children":3395},{},[3396],{"type":55,"value":3397},"Keep middleware focused:",{"type":55,"value":3399}," One concern per middleware",{"type":50,"tag":219,"props":3401,"children":3402},{},[3403,3408],{"type":50,"tag":71,"props":3404,"children":3405},{},[3406],{"type":55,"value":3407},"Handle errors gracefully:",{"type":55,"value":3409}," Don't let middleware crash functions",{"type":50,"tag":219,"props":3411,"children":3412},{},[3413,3418],{"type":50,"tag":71,"props":3414,"children":3415},{},[3416],{"type":55,"value":3417},"Consider performance:",{"type":55,"value":3419}," Middleware runs on every execution",{"type":50,"tag":219,"props":3421,"children":3422},{},[3423,3428],{"type":50,"tag":71,"props":3424,"children":3425},{},[3426],{"type":55,"value":3427},"Use proper typing:",{"type":55,"value":3429}," Let TypeScript infer middleware types",{"type":50,"tag":219,"props":3431,"children":3432},{},[3433,3438],{"type":50,"tag":71,"props":3434,"children":3435},{},[3436],{"type":55,"value":3437},"Test thoroughly:",{"type":55,"value":3439}," Middleware affects all functions that use it",{"type":50,"tag":295,"props":3441,"children":3443},{"id":3442},"common-use-cases-to-implement",[3444],{"type":55,"value":3445},"Common Use Cases to Implement",{"type":50,"tag":215,"props":3447,"children":3448},{},[3449,3459,3469,3479,3489,3499],{"type":50,"tag":219,"props":3450,"children":3451},{},[3452,3457],{"type":50,"tag":71,"props":3453,"children":3454},{},[3455],{"type":55,"value":3456},"Retry logic",{"type":55,"value":3458}," for transient failures",{"type":50,"tag":219,"props":3460,"children":3461},{},[3462,3467],{"type":50,"tag":71,"props":3463,"children":3464},{},[3465],{"type":55,"value":3466},"Circuit breakers",{"type":55,"value":3468}," for external service calls",{"type":50,"tag":219,"props":3470,"children":3471},{},[3472,3477],{"type":50,"tag":71,"props":3473,"children":3474},{},[3475],{"type":55,"value":3476},"Request\u002Fresponse logging",{"type":55,"value":3478}," for debugging",{"type":50,"tag":219,"props":3480,"children":3481},{},[3482,3487],{"type":50,"tag":71,"props":3483,"children":3484},{},[3485],{"type":55,"value":3486},"User context enrichment",{"type":55,"value":3488}," from external sources",{"type":50,"tag":219,"props":3490,"children":3491},{},[3492,3497],{"type":50,"tag":71,"props":3493,"children":3494},{},[3495],{"type":55,"value":3496},"Feature flags",{"type":55,"value":3498}," for gradual rollouts",{"type":50,"tag":219,"props":3500,"children":3501},{},[3502,3507],{"type":50,"tag":71,"props":3503,"children":3504},{},[3505],{"type":55,"value":3506},"Custom authentication",{"type":55,"value":3508}," and authorization checks",{"type":50,"tag":295,"props":3510,"children":3512},{"id":3511},"error-handling-in-middleware",[3513],{"type":55,"value":3514},"Error Handling in Middleware",{"type":50,"tag":302,"props":3516,"children":3518},{"className":304,"code":3517,"language":306,"meta":307,"style":307},"const robustMiddleware = new InngestMiddleware({\n  name: \"Robust Middleware\",\n  init() {\n    return {\n      onFunctionRun({ ctx, fn }) {\n        return {\n          transformOutput({ result }) {\n            try {\n              \u002F\u002F Your middleware logic here\n              return performTransformation(result);\n            } catch (middlewareError) {\n              \u002F\u002F Log error but don't break the function\n              console.error(\"Middleware error:\", middlewareError);\n\n              \u002F\u002F Return original result on middleware failure\n              return { result };\n            }\n          }\n        };\n      }\n    };\n  }\n});\n",[3519],{"type":50,"tag":123,"props":3520,"children":3521},{"__ignoreMap":307},[3522,3554,3582,3597,3608,3639,3650,3673,3685,3693,3723,3754,3762,3812,3819,3827,3846,3854,3861,3868,3875,3882,3889],{"type":50,"tag":313,"props":3523,"children":3524},{"class":315,"line":316},[3525,3529,3534,3538,3542,3546,3550],{"type":50,"tag":313,"props":3526,"children":3527},{"style":320},[3528],{"type":55,"value":323},{"type":50,"tag":313,"props":3530,"children":3531},{"style":326},[3532],{"type":55,"value":3533}," robustMiddleware ",{"type":50,"tag":313,"props":3535,"children":3536},{"style":332},[3537],{"type":55,"value":335},{"type":50,"tag":313,"props":3539,"children":3540},{"style":332},[3541],{"type":55,"value":340},{"type":50,"tag":313,"props":3543,"children":3544},{"style":343},[3545],{"type":55,"value":771},{"type":50,"tag":313,"props":3547,"children":3548},{"style":326},[3549],{"type":55,"value":351},{"type":50,"tag":313,"props":3551,"children":3552},{"style":332},[3553],{"type":55,"value":356},{"type":50,"tag":313,"props":3555,"children":3556},{"class":315,"line":359},[3557,3561,3565,3569,3574,3578],{"type":50,"tag":313,"props":3558,"children":3559},{"style":363},[3560],{"type":55,"value":843},{"type":50,"tag":313,"props":3562,"children":3563},{"style":332},[3564],{"type":55,"value":371},{"type":50,"tag":313,"props":3566,"children":3567},{"style":332},[3568],{"type":55,"value":376},{"type":50,"tag":313,"props":3570,"children":3571},{"style":379},[3572],{"type":55,"value":3573},"Robust Middleware",{"type":50,"tag":313,"props":3575,"children":3576},{"style":332},[3577],{"type":55,"value":387},{"type":50,"tag":313,"props":3579,"children":3580},{"style":332},[3581],{"type":55,"value":392},{"type":50,"tag":313,"props":3583,"children":3584},{"class":315,"line":395},[3585,3589,3593],{"type":50,"tag":313,"props":3586,"children":3587},{"style":363},[3588],{"type":55,"value":872},{"type":50,"tag":313,"props":3590,"children":3591},{"style":332},[3592],{"type":55,"value":877},{"type":50,"tag":313,"props":3594,"children":3595},{"style":332},[3596],{"type":55,"value":693},{"type":50,"tag":313,"props":3598,"children":3599},{"class":315,"line":413},[3600,3604],{"type":50,"tag":313,"props":3601,"children":3602},{"style":758},[3603],{"type":55,"value":935},{"type":50,"tag":313,"props":3605,"children":3606},{"style":332},[3607],{"type":55,"value":693},{"type":50,"tag":313,"props":3609,"children":3610},{"class":315,"line":30},[3611,3615,3619,3623,3627,3631,3635],{"type":50,"tag":313,"props":3612,"children":3613},{"style":363},[3614],{"type":55,"value":963},{"type":50,"tag":313,"props":3616,"children":3617},{"style":332},[3618],{"type":55,"value":968},{"type":50,"tag":313,"props":3620,"children":3621},{"style":971},[3622],{"type":55,"value":974},{"type":50,"tag":313,"props":3624,"children":3625},{"style":332},[3626],{"type":55,"value":424},{"type":50,"tag":313,"props":3628,"children":3629},{"style":971},[3630],{"type":55,"value":983},{"type":50,"tag":313,"props":3632,"children":3633},{"style":332},[3634],{"type":55,"value":988},{"type":50,"tag":313,"props":3636,"children":3637},{"style":332},[3638],{"type":55,"value":693},{"type":50,"tag":313,"props":3640,"children":3641},{"class":315,"line":446},[3642,3646],{"type":50,"tag":313,"props":3643,"children":3644},{"style":758},[3645],{"type":55,"value":1000},{"type":50,"tag":313,"props":3647,"children":3648},{"style":332},[3649],{"type":55,"value":693},{"type":50,"tag":313,"props":3651,"children":3652},{"class":315,"line":455},[3653,3657,3661,3665,3669],{"type":50,"tag":313,"props":3654,"children":3655},{"style":363},[3656],{"type":55,"value":1335},{"type":50,"tag":313,"props":3658,"children":3659},{"style":332},[3660],{"type":55,"value":968},{"type":50,"tag":313,"props":3662,"children":3663},{"style":971},[3664],{"type":55,"value":1344},{"type":50,"tag":313,"props":3666,"children":3667},{"style":332},[3668],{"type":55,"value":988},{"type":50,"tag":313,"props":3670,"children":3671},{"style":332},[3672],{"type":55,"value":693},{"type":50,"tag":313,"props":3674,"children":3675},{"class":315,"line":474},[3676,3681],{"type":50,"tag":313,"props":3677,"children":3678},{"style":758},[3679],{"type":55,"value":3680},"            try",{"type":50,"tag":313,"props":3682,"children":3683},{"style":332},[3684],{"type":55,"value":693},{"type":50,"tag":313,"props":3686,"children":3687},{"class":315,"line":484},[3688],{"type":50,"tag":313,"props":3689,"children":3690},{"style":427},[3691],{"type":55,"value":3692},"              \u002F\u002F Your middleware logic here\n",{"type":50,"tag":313,"props":3694,"children":3695},{"class":315,"line":507},[3696,3701,3706,3710,3715,3719],{"type":50,"tag":313,"props":3697,"children":3698},{"style":758},[3699],{"type":55,"value":3700},"              return",{"type":50,"tag":313,"props":3702,"children":3703},{"style":343},[3704],{"type":55,"value":3705}," performTransformation",{"type":50,"tag":313,"props":3707,"children":3708},{"style":363},[3709],{"type":55,"value":351},{"type":50,"tag":313,"props":3711,"children":3712},{"style":326},[3713],{"type":55,"value":3714},"result",{"type":50,"tag":313,"props":3716,"children":3717},{"style":363},[3718],{"type":55,"value":466},{"type":50,"tag":313,"props":3720,"children":3721},{"style":332},[3722],{"type":55,"value":471},{"type":50,"tag":313,"props":3724,"children":3725},{"class":315,"line":516},[3726,3730,3735,3740,3745,3750],{"type":50,"tag":313,"props":3727,"children":3728},{"style":332},[3729],{"type":55,"value":1162},{"type":50,"tag":313,"props":3731,"children":3732},{"style":758},[3733],{"type":55,"value":3734}," catch",{"type":50,"tag":313,"props":3736,"children":3737},{"style":363},[3738],{"type":55,"value":3739}," (",{"type":50,"tag":313,"props":3741,"children":3742},{"style":326},[3743],{"type":55,"value":3744},"middlewareError",{"type":50,"tag":313,"props":3746,"children":3747},{"style":363},[3748],{"type":55,"value":3749},") ",{"type":50,"tag":313,"props":3751,"children":3752},{"style":332},[3753],{"type":55,"value":356},{"type":50,"tag":313,"props":3755,"children":3756},{"class":315,"line":546},[3757],{"type":50,"tag":313,"props":3758,"children":3759},{"style":427},[3760],{"type":55,"value":3761},"              \u002F\u002F Log error but don't break the function\n",{"type":50,"tag":313,"props":3763,"children":3764},{"class":315,"line":563},[3765,3770,3774,3778,3782,3786,3791,3795,3799,3804,3808],{"type":50,"tag":313,"props":3766,"children":3767},{"style":326},[3768],{"type":55,"value":3769},"              console",{"type":50,"tag":313,"props":3771,"children":3772},{"style":332},[3773],{"type":55,"value":494},{"type":50,"tag":313,"props":3775,"children":3776},{"style":343},[3777],{"type":55,"value":3119},{"type":50,"tag":313,"props":3779,"children":3780},{"style":363},[3781],{"type":55,"value":351},{"type":50,"tag":313,"props":3783,"children":3784},{"style":332},[3785],{"type":55,"value":387},{"type":50,"tag":313,"props":3787,"children":3788},{"style":379},[3789],{"type":55,"value":3790},"Middleware error:",{"type":50,"tag":313,"props":3792,"children":3793},{"style":332},[3794],{"type":55,"value":387},{"type":50,"tag":313,"props":3796,"children":3797},{"style":332},[3798],{"type":55,"value":424},{"type":50,"tag":313,"props":3800,"children":3801},{"style":326},[3802],{"type":55,"value":3803}," middlewareError",{"type":50,"tag":313,"props":3805,"children":3806},{"style":363},[3807],{"type":55,"value":466},{"type":50,"tag":313,"props":3809,"children":3810},{"style":332},[3811],{"type":55,"value":471},{"type":50,"tag":313,"props":3813,"children":3814},{"class":315,"line":581},[3815],{"type":50,"tag":313,"props":3816,"children":3817},{"emptyLinePlaceholder":478},[3818],{"type":55,"value":481},{"type":50,"tag":313,"props":3820,"children":3821},{"class":315,"line":595},[3822],{"type":50,"tag":313,"props":3823,"children":3824},{"style":427},[3825],{"type":55,"value":3826},"              \u002F\u002F Return original result on middleware failure\n",{"type":50,"tag":313,"props":3828,"children":3829},{"class":315,"line":608},[3830,3834,3838,3842],{"type":50,"tag":313,"props":3831,"children":3832},{"style":758},[3833],{"type":55,"value":3700},{"type":50,"tag":313,"props":3835,"children":3836},{"style":332},[3837],{"type":55,"value":766},{"type":50,"tag":313,"props":3839,"children":3840},{"style":326},[3841],{"type":55,"value":1344},{"type":50,"tag":313,"props":3843,"children":3844},{"style":332},[3845],{"type":55,"value":1512},{"type":50,"tag":313,"props":3847,"children":3848},{"class":315,"line":663},[3849],{"type":50,"tag":313,"props":3850,"children":3851},{"style":332},[3852],{"type":55,"value":3853},"            }\n",{"type":50,"tag":313,"props":3855,"children":3856},{"class":315,"line":672},[3857],{"type":50,"tag":313,"props":3858,"children":3859},{"style":332},[3860],{"type":55,"value":1521},{"type":50,"tag":313,"props":3862,"children":3863},{"class":315,"line":696},[3864],{"type":50,"tag":313,"props":3865,"children":3866},{"style":332},[3867],{"type":55,"value":1530},{"type":50,"tag":313,"props":3869,"children":3870},{"class":315,"line":705},[3871],{"type":50,"tag":313,"props":3872,"children":3873},{"style":332},[3874],{"type":55,"value":1848},{"type":50,"tag":313,"props":3876,"children":3877},{"class":315,"line":714},[3878],{"type":50,"tag":313,"props":3879,"children":3880},{"style":332},[3881],{"type":55,"value":1857},{"type":50,"tag":313,"props":3883,"children":3884},{"class":315,"line":1188},[3885],{"type":50,"tag":313,"props":3886,"children":3887},{"style":332},[3888],{"type":55,"value":711},{"type":50,"tag":313,"props":3890,"children":3891},{"class":315,"line":1205},[3892,3896,3900],{"type":50,"tag":313,"props":3893,"children":3894},{"style":332},[3895],{"type":55,"value":461},{"type":50,"tag":313,"props":3897,"children":3898},{"style":326},[3899],{"type":55,"value":466},{"type":50,"tag":313,"props":3901,"children":3902},{"style":332},[3903],{"type":55,"value":471},{"type":50,"tag":295,"props":3905,"children":3907},{"id":3906},"testing-middleware",[3908],{"type":55,"value":3909},"Testing Middleware",{"type":50,"tag":58,"props":3911,"children":3912},{},[3913,3915,3921,3923,3929],{"type":55,"value":3914},"Use Inngest's testing utilities (",{"type":50,"tag":123,"props":3916,"children":3918},{"className":3917},[],[3919],{"type":55,"value":3920},"createMockContext",{"type":55,"value":3922},", ",{"type":50,"tag":123,"props":3924,"children":3926},{"className":3925},[],[3927],{"type":55,"value":3928},"createMockFunction",{"type":55,"value":3930},") to unit test middleware behavior.",{"type":50,"tag":58,"props":3932,"children":3933},{},[3934],{"type":50,"tag":71,"props":3935,"children":3936},{},[3937],{"type":55,"value":3938},"For complete implementation examples and advanced patterns, see:",{"type":50,"tag":215,"props":3940,"children":3941},{},[3942,3949],{"type":50,"tag":219,"props":3943,"children":3944},{},[3945],{"type":50,"tag":79,"props":3946,"children":3947},{"href":1895},[3948],{"type":55,"value":1898},{"type":50,"tag":219,"props":3950,"children":3951},{},[3952],{"type":50,"tag":79,"props":3953,"children":3954},{"href":1944},[3955],{"type":55,"value":3956},"Built-in Middleware Reference",{"type":50,"tag":3958,"props":3959,"children":3960},"style",{},[3961],{"type":55,"value":3962},"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":3964,"total":581},[3965,3983,3998,4012,4025,4038,4053,4066,4078,4091,4099,4113],{"slug":3966,"name":3966,"fn":3967,"description":3968,"org":3969,"tags":3970,"stars":26,"repoUrl":27,"updatedAt":3982},"inngest-agent-evals","build and debug Inngest agent evals","Use when building, migrating, or debugging Agent Evals on Inngest: scoring AI agent or workflow outcomes, deferred scorers, sessions, traces, step experiments, experiment variant attribution, Insights queries, or production eval loops for prompts, models, tools, providers, and agent behavior. Covers TypeScript SDK v4 scoring beta APIs, `scoreMiddleware`, `step.score`, `inngest.score`, `createScorer`, `defer`, `group.experiment`, `experimentRef`, `meta.sessions`, and when to use durable workflow primitives for outcome-based evaluation.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3971,3974,3977,3978,3979],{"name":3972,"slug":3973,"type":15},"Agents","agents",{"name":3975,"slug":3976,"type":15},"Evals","evals",{"name":9,"slug":8,"type":15},{"name":13,"slug":14,"type":15},{"name":3980,"slug":3981,"type":15},"Workflow Automation","workflow-automation","2026-07-12T07:36:51.711641",{"slug":3984,"name":3984,"fn":3985,"description":3986,"org":3987,"tags":3988,"stars":26,"repoUrl":27,"updatedAt":3997},"inngest-agents","build durable AI agent workflows","Use when building durable AI agents or agentic workflows with Inngest and AgentKit, including model calls, tool calls, multi-agent networks, human approval, realtime progress, provider rate limits, crash-safe execution, and Agent Evals handoff. Covers AgentKit, `step.ai`, `step.run`, `step.waitForEvent`, native realtime, and when to use lower-level Inngest primitives instead of an in-memory agent loop. Use `inngest-agent-evals` with this skill when the user wants scoring, sessions, experiments, deferred scorers, or outcome-based evaluation for the agent.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3989,3990,3993,3994],{"name":3972,"slug":3973,"type":15},{"name":3991,"slug":3992,"type":15},"Automation","automation",{"name":9,"slug":8,"type":15},{"name":3995,"slug":3996,"type":15},"LLM","llm","2026-07-12T07:36:45.984181",{"slug":3999,"name":3999,"fn":4000,"description":4001,"org":4002,"tags":4003,"stars":26,"repoUrl":27,"updatedAt":4011},"inngest-api","interact with Inngest REST API","Use when the user explicitly asks for the Inngest REST API v2, raw HTTP, OpenAPI, API docs, API authentication, or an endpoint that the Inngest CLI does not expose. Covers api-docs.inngest.com, llms.txt, the OpenAPI v2 spec, Bearer authentication with API keys or signing keys, production and local base URLs, raw curl\u002Ffetch requests, request-shape discovery, pagination, secret redaction, and when to prefer the `inngest-api-cli` skill instead.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4004,4007,4010],{"name":4005,"slug":4006,"type":15},"API Development","api-development",{"name":4008,"slug":4009,"type":15},"REST API","rest-api",{"name":3980,"slug":3981,"type":15},"2026-07-12T07:36:39.364409",{"slug":4013,"name":4013,"fn":4014,"description":4015,"org":4016,"tags":4017,"stars":26,"repoUrl":27,"updatedAt":4024},"inngest-api-cli","operate Inngest API resources via CLI","Use when operating Inngest API resources from the terminal with `npx inngest-cli@latest api`: Cloud\u002Flocal run debugging, event-run lookup, function traces, function invocation, app syncs, webhooks, environments, keys, account checks, and Insights queries. Provides prescriptive command routing for agents: which CLI command to run for a run ID, event ID, app ID, function ID, Cloud environment, API key, missing ID, or potentially mutating operation. Use `inngest-cli` for dev server setup\u002Fgeneral CLI workflows and `inngest-api` only when raw REST API v2 docs or OpenAPI fallback are needed.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4018,4019,4020,4023],{"name":4005,"slug":4006,"type":15},{"name":3991,"slug":3992,"type":15},{"name":4021,"slug":4022,"type":15},"CLI","cli",{"name":9,"slug":8,"type":15},"2026-07-12T07:36:47.58183",{"slug":4026,"name":4026,"fn":4027,"description":4028,"org":4029,"tags":4030,"stars":26,"repoUrl":27,"updatedAt":4037},"inngest-brownfield-audit","audit codebases for Inngest integration","Use when analyzing an existing TypeScript or JavaScript codebase to decide where and how to introduce Inngest. Covers repository discovery, framework and package detection, finding durability gaps in HTTP handlers, webhooks, cron jobs, queues, long-running jobs, AI agents, Agent Evals, polling loops, eval loops, and side-effect-heavy code, then producing and implementing an incremental integration plan.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4031,4032,4035,4036],{"name":3991,"slug":3992,"type":15},{"name":4033,"slug":4034,"type":15},"Code Analysis","code-analysis",{"name":18,"slug":19,"type":15},{"name":9,"slug":8,"type":15},"2026-07-12T07:36:55.811247",{"slug":4039,"name":4039,"fn":4040,"description":4041,"org":4042,"tags":4043,"stars":26,"repoUrl":27,"updatedAt":4052},"inngest-cli","configure Inngest CLI and dev server","Use when installing or running the Inngest CLI and Dev Server for local development, local testing, serve endpoint debugging, Docker or Docker Compose setup, MCP configuration, self-hosted `inngest start`, or deployment workflow checks. Covers `inngest dev`, `inngest start`, auto-discovery, config files, environment variables, `@inngest\u002Ftest`, local event sending, platform gotchas, and production\u002Fself-hosted server flags.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4044,4045,4048,4049],{"name":4021,"slug":4022,"type":15},{"name":4046,"slug":4047,"type":15},"Docker","docker",{"name":9,"slug":8,"type":15},{"name":4050,"slug":4051,"type":15},"Local Development","local-development","2026-07-12T07:36:40.694652",{"slug":4054,"name":4054,"fn":4055,"description":4056,"org":4057,"tags":4058,"stars":26,"repoUrl":27,"updatedAt":4065},"inngest-durable-functions","build durable and retry-safe functions","Use when building functions that must survive process crashes, retry automatically on failure, run on a schedule, react to events, or maintain state across infrastructure failures — e.g., webhook handlers that drop events, flaky cron jobs, background jobs that fail mid-execution, or workflows that need to resume where they left off. Covers Inngest function configuration, triggers (events, cron, invoke), step execution and memoization, idempotency, cancellation, error handling, retries, logging, and observability.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4059,4060,4063,4064],{"name":3991,"slug":3992,"type":15},{"name":4061,"slug":4062,"type":15},"Backend","backend",{"name":9,"slug":8,"type":15},{"name":3980,"slug":3981,"type":15},"2026-07-12T07:36:57.141023",{"slug":4067,"name":4067,"fn":4068,"description":4069,"org":4070,"tags":4071,"stars":26,"repoUrl":27,"updatedAt":4077},"inngest-events","design event-driven workflows","Use when designing event-driven workflows, decoupling services, implementing fan-out patterns (one trigger, many downstream handlers), implementing idempotent event handling with IDs (24-hour dedupe window), or handling at-least-once delivery from external sources like Stripe webhooks. Covers Inngest event schema, payload format, naming conventions, IDs for idempotency, the ts param, fan-out patterns, and system events like inngest\u002Ffunction.failed.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4072,4075,4076],{"name":4073,"slug":4074,"type":15},"Data Pipeline","data-pipeline",{"name":9,"slug":8,"type":15},{"name":3980,"slug":3981,"type":15},"2026-07-12T07:36:44.685364",{"slug":4079,"name":4079,"fn":4080,"description":4081,"org":4082,"tags":4083,"stars":26,"repoUrl":27,"updatedAt":4090},"inngest-flow-control","manage API rate limits and load","Use when handling external API rate limits (e.g., OpenAI 429s, HubSpot or Stripe rate limits), preventing duplicate work from rapid event bursts (debouncing user actions), spreading load over time, ensuring per-tenant fairness, processing events in batches, limiting concurrent runs of the same operation, or assigning priority to important runs. Covers Inngest flow control: concurrency limits with keys, throttling, rate limiting, debounce, priority, singleton, and event batching.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4084,4085,4086,4087],{"name":4005,"slug":4006,"type":15},{"name":3991,"slug":3992,"type":15},{"name":9,"slug":8,"type":15},{"name":4088,"slug":4089,"type":15},"Performance","performance","2026-07-12T07:36:52.987451",{"slug":4,"name":4,"fn":5,"description":6,"org":4092,"tags":4093,"stars":26,"repoUrl":27,"updatedAt":28},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4094,4095,4096,4097,4098],{"name":18,"slug":19,"type":15},{"name":9,"slug":8,"type":15},{"name":21,"slug":22,"type":15},{"name":13,"slug":14,"type":15},{"name":24,"slug":25,"type":15},{"slug":128,"name":128,"fn":4100,"description":4101,"org":4102,"tags":4103,"stars":26,"repoUrl":27,"updatedAt":4112},"stream durable workflow updates to UI","Use when streaming durable workflow updates to a UI in real time — live order status pages that animate as steps complete, AI agent token streaming from a function to the browser, log tailing for long-running jobs, or human-in-the-loop approval flows that publish a prompt and wait for a user reply. Covers Inngest v4 native realtime: defining typed channels, publishing from inside step.run, minting subscription tokens via server actions, and consuming the stream from React\u002FNext.js client components.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4104,4105,4108,4109],{"name":3991,"slug":3992,"type":15},{"name":4106,"slug":4107,"type":15},"Frontend","frontend",{"name":9,"slug":8,"type":15},{"name":4110,"slug":4111,"type":15},"Real-time","real-time","2026-07-12T07:36:48.895092",{"slug":4114,"name":4114,"fn":4115,"description":4116,"org":4117,"tags":4118,"stars":26,"repoUrl":27,"updatedAt":4124},"inngest-setup","build durable TypeScript workflows","Use when adding durable execution to a TypeScript project — building retry-safe webhook handlers, background jobs that survive crashes, scheduled tasks, or long-running workflows that outlive a single request. Covers Inngest SDK installation, client config, environment variables, serve endpoints (Next.js, Express, Hono, Fastify), connect-as-worker mode, and the local dev server.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4119,4120,4121,4122],{"name":3991,"slug":3992,"type":15},{"name":4061,"slug":4062,"type":15},{"name":9,"slug":8,"type":15},{"name":4123,"slug":306,"type":15},"TypeScript","2026-07-12T07:36:42.004122",{"items":4126,"total":581},[4127,4135,4142,4148,4155,4162,4169],{"slug":3966,"name":3966,"fn":3967,"description":3968,"org":4128,"tags":4129,"stars":26,"repoUrl":27,"updatedAt":3982},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4130,4131,4132,4133,4134],{"name":3972,"slug":3973,"type":15},{"name":3975,"slug":3976,"type":15},{"name":9,"slug":8,"type":15},{"name":13,"slug":14,"type":15},{"name":3980,"slug":3981,"type":15},{"slug":3984,"name":3984,"fn":3985,"description":3986,"org":4136,"tags":4137,"stars":26,"repoUrl":27,"updatedAt":3997},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4138,4139,4140,4141],{"name":3972,"slug":3973,"type":15},{"name":3991,"slug":3992,"type":15},{"name":9,"slug":8,"type":15},{"name":3995,"slug":3996,"type":15},{"slug":3999,"name":3999,"fn":4000,"description":4001,"org":4143,"tags":4144,"stars":26,"repoUrl":27,"updatedAt":4011},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4145,4146,4147],{"name":4005,"slug":4006,"type":15},{"name":4008,"slug":4009,"type":15},{"name":3980,"slug":3981,"type":15},{"slug":4013,"name":4013,"fn":4014,"description":4015,"org":4149,"tags":4150,"stars":26,"repoUrl":27,"updatedAt":4024},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4151,4152,4153,4154],{"name":4005,"slug":4006,"type":15},{"name":3991,"slug":3992,"type":15},{"name":4021,"slug":4022,"type":15},{"name":9,"slug":8,"type":15},{"slug":4026,"name":4026,"fn":4027,"description":4028,"org":4156,"tags":4157,"stars":26,"repoUrl":27,"updatedAt":4037},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4158,4159,4160,4161],{"name":3991,"slug":3992,"type":15},{"name":4033,"slug":4034,"type":15},{"name":18,"slug":19,"type":15},{"name":9,"slug":8,"type":15},{"slug":4039,"name":4039,"fn":4040,"description":4041,"org":4163,"tags":4164,"stars":26,"repoUrl":27,"updatedAt":4052},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4165,4166,4167,4168],{"name":4021,"slug":4022,"type":15},{"name":4046,"slug":4047,"type":15},{"name":9,"slug":8,"type":15},{"name":4050,"slug":4051,"type":15},{"slug":4054,"name":4054,"fn":4055,"description":4056,"org":4170,"tags":4171,"stars":26,"repoUrl":27,"updatedAt":4065},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[4172,4173,4174,4175],{"name":3991,"slug":3992,"type":15},{"name":4061,"slug":4062,"type":15},{"name":9,"slug":8,"type":15},{"name":3980,"slug":3981,"type":15}]