inngest 4.12.1 → 4.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/components/execution/InngestExecution.cjs.map +1 -1
  3. package/components/execution/InngestExecution.d.cts +3 -1
  4. package/components/execution/InngestExecution.d.cts.map +1 -1
  5. package/components/execution/InngestExecution.d.ts +3 -1
  6. package/components/execution/InngestExecution.d.ts.map +1 -1
  7. package/components/execution/InngestExecution.js.map +1 -1
  8. package/components/execution/engine.cjs +49 -9
  9. package/components/execution/engine.cjs.map +1 -1
  10. package/components/execution/engine.d.cts +3 -1
  11. package/components/execution/engine.d.cts.map +1 -1
  12. package/components/execution/engine.d.ts +3 -1
  13. package/components/execution/engine.d.ts.map +1 -1
  14. package/components/execution/engine.js +49 -9
  15. package/components/execution/engine.js.map +1 -1
  16. package/components/execution/lazyOps.cjs +3 -0
  17. package/components/execution/lazyOps.cjs.map +1 -1
  18. package/components/execution/lazyOps.js +4 -1
  19. package/components/execution/lazyOps.js.map +1 -1
  20. package/components/execution/otel/middleware.d.cts +5 -5
  21. package/components/execution/otel/middleware.d.ts +5 -5
  22. package/components/realtime/types.d.cts +4 -4
  23. package/components/realtime/types.d.cts.map +1 -1
  24. package/components/realtime/types.d.ts +4 -4
  25. package/components/realtime/types.d.ts.map +1 -1
  26. package/helpers/functions.cjs +1 -1
  27. package/helpers/functions.cjs.map +1 -1
  28. package/helpers/functions.js +1 -1
  29. package/helpers/functions.js.map +1 -1
  30. package/package.json +1 -1
  31. package/types.cjs.map +1 -1
  32. package/types.d.cts +31 -18
  33. package/types.d.cts.map +1 -1
  34. package/types.d.ts +31 -18
  35. package/types.d.ts.map +1 -1
  36. package/types.js.map +1 -1
  37. package/version.cjs +1 -1
  38. package/version.cjs.map +1 -1
  39. package/version.d.cts +1 -1
  40. package/version.d.ts +1 -1
  41. package/version.js +1 -1
  42. package/version.js.map +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # inngest
2
2
 
3
+ ## 4.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1630](https://github.com/inngest/inngest-js/pull/1630) [`7b5907e4`](https://github.com/inngest/inngest-js/commit/7b5907e44f9662cd64c45ede8802d0d2d42dc8c3) Thanks [@Linell](https://github.com/Linell)! - Added support for aborting deferred runs via defer().abort()
8
+
3
9
  ## 4.12.1
4
10
 
5
11
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"InngestExecution.cjs","names":["ExecutionVersion","options: InngestExecutionOptions","debugPrefix"],"sources":["../../../src/components/execution/InngestExecution.ts"],"sourcesContent":["import Debug, { type Debugger } from \"debug\";\nimport { debugPrefix, ExecutionVersion } from \"../../helpers/consts.ts\";\nimport type { ServerTiming } from \"../../helpers/ServerTiming.ts\";\nimport type { MaybePromise, Simplify } from \"../../helpers/types.ts\";\nimport type {\n Context,\n IncomingOp,\n InternalCheckpointingOptions,\n OutgoingOp,\n StepMode,\n} from \"../../types.ts\";\nimport type { Inngest } from \"../Inngest.ts\";\nimport type { ActionResponse } from \"../InngestCommHandler.ts\";\nimport type { InngestFunction } from \"../InngestFunction.ts\";\nimport type {\n MetadataKind,\n MetadataOpcode,\n MetadataScope,\n} from \"../InngestMetadata.ts\";\nimport type { Middleware } from \"../middleware/middleware.ts\";\n\n// Re-export ExecutionVersion so it's correctly recognized as an enum and not\n// just a type. This can be lost when bundling if we don't re-export it here.\n// See `pnpm run test:dist`.\nexport { ExecutionVersion };\n\n/**\n * The possible results of an execution.\n */\nexport interface ExecutionResults {\n \"function-resolved\": { data: unknown };\n \"step-ran\": { step: OutgoingOp; retriable?: boolean | string };\n \"function-rejected\": { error: unknown; retriable: boolean | string };\n \"steps-found\": { steps: [OutgoingOp, ...OutgoingOp[]] };\n \"step-not-found\": {\n step: OutgoingOp;\n foundSteps: BasicFoundStep[];\n totalFoundSteps: number;\n };\n\n /**\n * Indicates that we need to relinquish control back to Inngest in order to\n * change step modes.\n */\n \"change-mode\": {\n to: StepMode;\n token: string;\n };\n}\n\nexport type ExecutionResult = {\n [K in keyof ExecutionResults]: Simplify<\n {\n type: K;\n ctx: Context.Any;\n ops: Record<string, MemoizedOp>;\n } & ExecutionResults[K]\n >;\n}[keyof ExecutionResults];\n\nexport interface BasicFoundStep {\n id: string;\n displayName?: string;\n}\n\nexport type ExecutionResultHandler<T = ActionResponse> = (\n result: ExecutionResult,\n) => MaybePromise<T>;\n\nexport type ExecutionResultHandlers<T = ActionResponse> = {\n [E in ExecutionResult as E[\"type\"]]: (result: E) => MaybePromise<T>;\n};\n\nexport interface MemoizedOp extends IncomingOp {\n /**\n * If the step has been hit during this run, these will be the arguments\n * passed to it.\n */\n rawArgs?: unknown[];\n fulfilled?: boolean;\n\n /**\n * The promise that has been returned to userland code.\n */\n promise?: Promise<unknown>;\n seen?: boolean;\n}\n\n/**\n * The preferred execution version that will be used by the SDK when handling\n * brand new runs where the Executor is allowing us to choose.\n *\n * Changing this should not ever be a breaking change, as this will only change\n * new runs, not existing ones.\n */\nexport const PREFERRED_ASYNC_EXECUTION_VERSION =\n ExecutionVersion.V2 satisfies ExecutionVersion;\n\n/**\n * Options for creating a new {@link InngestExecution} instance.\n */\nexport interface InngestExecutionOptions {\n client: Inngest.Any;\n fn: InngestFunction.Any;\n\n /**\n * The UUID that represents this function in Inngest.\n *\n * This is used to reference the function during async checkpointing, when we\n * know the function/run already exists and just wish to reference it\n * directly.\n */\n internalFnId?: string;\n reqArgs: unknown[];\n runId: string;\n data: Omit<Context.Any, \"step\" | \"group\" | \"publish\" | \"defer\">;\n stepState: Record<string, MemoizedOp>;\n\n /**\n * A map of hashed defer step IDs to their backend-side metadata\n * (e.g. `{ abortable: true }`). Defer ops are not steps in the\n * memoization sense — they don't produce results — but the backend\n * tracks which ones it has already received so the SDK can avoid\n * re-emitting them on replay.\n */\n priorDefers?: Record<string, unknown>;\n\n stepCompletionOrder: string[];\n stepMode: StepMode;\n checkpointingConfig?: InternalCheckpointingOptions;\n\n /**\n * If this execution is being run from a queue job, this will be an identifier\n * used to reference this execution in Inngest. SDKs are expected to parrot\n * this back in some responses to correctly attribute actions to this queue\n * item.\n */\n queueItemId?: string;\n\n /**\n * Unique identifier for each execution request\n */\n requestId?: string;\n\n /**\n * Incrementing ID used to denote the generation in which this job was queued\n */\n generationId?: number;\n\n /**\n * Time the SDK starts handling an execution request. Format is unix millis.\n */\n requestStartedAt?: number;\n\n /**\n * Headers to be sent with any request to Inngest during this execution.\n */\n headers: Record<string, string>;\n requestedRunStep?: string;\n timer?: ServerTiming;\n /**\n * Which handler variant is being executed. `\"failure\"` skips\n * trigger-schema validation and resolves `onFailure` instead of the\n * main handler. `\"defer\"` marks the fn as a standalone defer function\n * (created via `createDefer`); incoming event data is validated\n * against the defer function's schema.\n *\n * @default \"main\"\n */\n handlerKind?: \"main\" | \"failure\" | \"defer\";\n\n /**\n * Whether this execution is part of a Durable Endpoint flow. Could be either\n * sync mode (request not from Inngest) or async mode (request from Inngest).\n *\n * @default false\n */\n isDurableEndpoint?: boolean;\n\n disableImmediateExecution?: boolean;\n\n /**\n * Information about the incoming HTTP request that triggered this execution.\n * Used by middleware `wrapRequest` hooks.\n */\n requestInfo?: Middleware.Request;\n\n /**\n * Pre-created middleware instances to use for this execution. When provided,\n * the execution will use these instead of instantiating new ones from the\n * client. This ensures `wrapRequest` and other hooks share state on `this`.\n */\n middlewareInstances?: Middleware.BaseMiddleware[];\n\n /**\n * Whether the client accepts SSE (`Accept: text/event-stream`). When true,\n * the execution engine may deliver the result as an SSE stream even if\n * `stream.push()` was not called.\n */\n acceptsSse?: boolean;\n\n /**\n * Provide the ability to transform the context passed to the function before\n * the execution starts.\n */\n transformCtx?: (ctx: Readonly<Context.Any>) => Context.Any;\n\n /**\n * A hook that is called to create an {@link ActionResponse} from the returned\n * value of an execution.\n *\n * This is required for checkpointing executions.\n */\n createResponse?: (data: unknown) => MaybePromise<ActionResponse>;\n}\n\nexport type InngestExecutionFactory = (\n options: InngestExecutionOptions,\n) => IInngestExecution;\n\nexport class InngestExecution {\n protected devDebug: Debugger;\n\n constructor(protected options: InngestExecutionOptions) {\n this.devDebug = Debug(`${debugPrefix}:${this.options.runId}`);\n }\n}\n\nexport interface IInngestExecution {\n version: ExecutionVersion;\n start(): Promise<ExecutionResult>;\n\n addMetadata(\n stepId: string,\n kind: MetadataKind,\n scope: MetadataScope,\n op: MetadataOpcode,\n values: Record<string, unknown>,\n ): boolean;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+FA,MAAa,oCACXA,gCAAiB;AA4HnB,IAAa,mBAAb,MAA8B;CAC5B,AAAU;CAEV,YAAY,AAAUC,SAAkC;EAAlC;AACpB,OAAK,8BAAiB,GAAGC,2BAAY,GAAG,KAAK,QAAQ,QAAQ"}
1
+ {"version":3,"file":"InngestExecution.cjs","names":["ExecutionVersion","options: InngestExecutionOptions","debugPrefix"],"sources":["../../../src/components/execution/InngestExecution.ts"],"sourcesContent":["import Debug, { type Debugger } from \"debug\";\nimport { debugPrefix, ExecutionVersion } from \"../../helpers/consts.ts\";\nimport type { ServerTiming } from \"../../helpers/ServerTiming.ts\";\nimport type { MaybePromise, Simplify } from \"../../helpers/types.ts\";\nimport type {\n Context,\n IncomingOp,\n InternalCheckpointingOptions,\n OutgoingOp,\n StepMode,\n} from \"../../types.ts\";\nimport type { Inngest } from \"../Inngest.ts\";\nimport type { ActionResponse } from \"../InngestCommHandler.ts\";\nimport type { InngestFunction } from \"../InngestFunction.ts\";\nimport type {\n MetadataKind,\n MetadataOpcode,\n MetadataScope,\n} from \"../InngestMetadata.ts\";\nimport type { Middleware } from \"../middleware/middleware.ts\";\n\n// Re-export ExecutionVersion so it's correctly recognized as an enum and not\n// just a type. This can be lost when bundling if we don't re-export it here.\n// See `pnpm run test:dist`.\nexport { ExecutionVersion };\n\n/**\n * The possible results of an execution.\n */\nexport interface ExecutionResults {\n \"function-resolved\": { data: unknown };\n \"step-ran\": { step: OutgoingOp; retriable?: boolean | string };\n \"function-rejected\": { error: unknown; retriable: boolean | string };\n \"steps-found\": { steps: [OutgoingOp, ...OutgoingOp[]] };\n \"step-not-found\": {\n step: OutgoingOp;\n foundSteps: BasicFoundStep[];\n totalFoundSteps: number;\n };\n\n /**\n * Indicates that we need to relinquish control back to Inngest in order to\n * change step modes.\n */\n \"change-mode\": {\n to: StepMode;\n token: string;\n };\n}\n\nexport type ExecutionResult = {\n [K in keyof ExecutionResults]: Simplify<\n {\n type: K;\n ctx: Context.Any;\n ops: Record<string, MemoizedOp>;\n } & ExecutionResults[K]\n >;\n}[keyof ExecutionResults];\n\nexport interface BasicFoundStep {\n id: string;\n displayName?: string;\n}\n\nexport type ExecutionResultHandler<T = ActionResponse> = (\n result: ExecutionResult,\n) => MaybePromise<T>;\n\nexport type ExecutionResultHandlers<T = ActionResponse> = {\n [E in ExecutionResult as E[\"type\"]]: (result: E) => MaybePromise<T>;\n};\n\nexport interface MemoizedOp extends IncomingOp {\n /**\n * If the step has been hit during this run, these will be the arguments\n * passed to it.\n */\n rawArgs?: unknown[];\n fulfilled?: boolean;\n\n /**\n * The promise that has been returned to userland code.\n */\n promise?: Promise<unknown>;\n seen?: boolean;\n}\n\n/**\n * The preferred execution version that will be used by the SDK when handling\n * brand new runs where the Executor is allowing us to choose.\n *\n * Changing this should not ever be a breaking change, as this will only change\n * new runs, not existing ones.\n */\nexport const PREFERRED_ASYNC_EXECUTION_VERSION =\n ExecutionVersion.V2 satisfies ExecutionVersion;\n\n/**\n * Options for creating a new {@link InngestExecution} instance.\n */\nexport interface InngestExecutionOptions {\n client: Inngest.Any;\n fn: InngestFunction.Any;\n\n /**\n * The UUID that represents this function in Inngest.\n *\n * This is used to reference the function during async checkpointing, when we\n * know the function/run already exists and just wish to reference it\n * directly.\n */\n internalFnId?: string;\n reqArgs: unknown[];\n runId: string;\n data: Omit<Context.Any, \"step\" | \"group\" | \"publish\" | \"defer\">;\n stepState: Record<string, MemoizedOp>;\n\n /**\n * A map of hashed defer step IDs to their backend-side metadata\n * (e.g. `{ abortable: true }`). Defer ops are not steps in the\n * memoization sense — they don't produce results — but the backend\n * tracks which ones it has already received so the SDK can avoid\n * re-emitting them on replay.\n */\n priorDefers?: Record<string, { abortable?: boolean }>;\n\n stepCompletionOrder: string[];\n stepMode: StepMode;\n checkpointingConfig?: InternalCheckpointingOptions;\n\n /**\n * If this execution is being run from a queue job, this will be an identifier\n * used to reference this execution in Inngest. SDKs are expected to parrot\n * this back in some responses to correctly attribute actions to this queue\n * item.\n */\n queueItemId?: string;\n\n /**\n * Unique identifier for each execution request\n */\n requestId?: string;\n\n /**\n * Incrementing ID used to denote the generation in which this job was queued\n */\n generationId?: number;\n\n /**\n * Time the SDK starts handling an execution request. Format is unix millis.\n */\n requestStartedAt?: number;\n\n /**\n * Headers to be sent with any request to Inngest during this execution.\n */\n headers: Record<string, string>;\n requestedRunStep?: string;\n timer?: ServerTiming;\n /**\n * Which handler variant is being executed. `\"failure\"` skips\n * trigger-schema validation and resolves `onFailure` instead of the\n * main handler. `\"defer\"` marks the fn as a standalone defer function\n * (created via `createDefer`); incoming event data is validated\n * against the defer function's schema.\n *\n * @default \"main\"\n */\n handlerKind?: \"main\" | \"failure\" | \"defer\";\n\n /**\n * Whether this execution is part of a Durable Endpoint flow. Could be either\n * sync mode (request not from Inngest) or async mode (request from Inngest).\n *\n * @default false\n */\n isDurableEndpoint?: boolean;\n\n disableImmediateExecution?: boolean;\n\n /**\n * Information about the incoming HTTP request that triggered this execution.\n * Used by middleware `wrapRequest` hooks.\n */\n requestInfo?: Middleware.Request;\n\n /**\n * Pre-created middleware instances to use for this execution. When provided,\n * the execution will use these instead of instantiating new ones from the\n * client. This ensures `wrapRequest` and other hooks share state on `this`.\n */\n middlewareInstances?: Middleware.BaseMiddleware[];\n\n /**\n * Whether the client accepts SSE (`Accept: text/event-stream`). When true,\n * the execution engine may deliver the result as an SSE stream even if\n * `stream.push()` was not called.\n */\n acceptsSse?: boolean;\n\n /**\n * Provide the ability to transform the context passed to the function before\n * the execution starts.\n */\n transformCtx?: (ctx: Readonly<Context.Any>) => Context.Any;\n\n /**\n * A hook that is called to create an {@link ActionResponse} from the returned\n * value of an execution.\n *\n * This is required for checkpointing executions.\n */\n createResponse?: (data: unknown) => MaybePromise<ActionResponse>;\n}\n\nexport type InngestExecutionFactory = (\n options: InngestExecutionOptions,\n) => IInngestExecution;\n\nexport class InngestExecution {\n protected devDebug: Debugger;\n\n constructor(protected options: InngestExecutionOptions) {\n this.devDebug = Debug(`${debugPrefix}:${this.options.runId}`);\n }\n}\n\nexport interface IInngestExecution {\n version: ExecutionVersion;\n start(): Promise<ExecutionResult>;\n\n addMetadata(\n stepId: string,\n kind: MetadataKind,\n scope: MetadataScope,\n op: MetadataOpcode,\n values: Record<string, unknown>,\n ): boolean;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+FA,MAAa,oCACXA,gCAAiB;AA4HnB,IAAa,mBAAb,MAA8B;CAC5B,AAAU;CAEV,YAAY,AAAUC,SAAkC;EAAlC;AACpB,OAAK,8BAAiB,GAAGC,2BAAY,GAAG,KAAK,QAAQ,QAAQ"}
@@ -102,7 +102,9 @@ interface InngestExecutionOptions {
102
102
  * tracks which ones it has already received so the SDK can avoid
103
103
  * re-emitting them on replay.
104
104
  */
105
- priorDefers?: Record<string, unknown>;
105
+ priorDefers?: Record<string, {
106
+ abortable?: boolean;
107
+ }>;
106
108
  stepCompletionOrder: string[];
107
109
  stepMode: StepMode;
108
110
  checkpointingConfig?: InternalCheckpointingOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"InngestExecution.d.cts","names":[],"sources":["../../../src/components/execution/InngestExecution.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;UA6BiB,gBAAA;;;;;UAEK;;;;;;;;IAFL,KAAA,EAAA,CAIU,UAJM,EAAA,GAIS,UAJT,EAAA,CAAA;EAAA,CAAA;kBAEX,EAAA;IAEK,IAAA,EAEjB,UAFiB;IAA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OAAA,CAAQ,SAAS,OAAA,CAAQ;;;;;;;sCAQnB,aAAa;;KAGvC,uBAAA,aACD,4BACN;cAEQ,gBAAA;qBAGoB;sBAFX;uBAEW;;UAKhB,iBAAA;WACN;WACA,QAAQ;oCAIT,qBACC,mBACH,wBACI"}
@@ -102,7 +102,9 @@ interface InngestExecutionOptions {
102
102
  * tracks which ones it has already received so the SDK can avoid
103
103
  * re-emitting them on replay.
104
104
  */
105
- priorDefers?: Record<string, unknown>;
105
+ priorDefers?: Record<string, {
106
+ abortable?: boolean;
107
+ }>;
106
108
  stepCompletionOrder: string[];
107
109
  stepMode: StepMode;
108
110
  checkpointingConfig?: InternalCheckpointingOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"InngestExecution.d.ts","names":[],"sources":["../../../src/components/execution/InngestExecution.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;UA6BiB,gBAAA;;;;;UAEK;;;;;;;;IAFL,KAAA,EAAA,CAIU,UAJM,EAAA,GAIS,UAJT,EAAA,CAAA;EAAA,CAAA;kBAEX,EAAA;IAEK,IAAA,EAEjB,UAFiB;IAAe,UAAA,EAG1B,cAH0B,EAAA;IAEhC,eAAA,EAAA,MAAA;;;;AAeV;;eACc,EAAA;IAEF,EAAA,EARJ,QAQI;IACD,KAAA,EAAQ,MAAA;;;AAEX,KANI,eAAA,GAMJ,QAAiB,MALX,gBAKW,GALQ,QAKR,CAAA;EALQ,IAAA,EAErB,CAFqB;EAOzB,GAAA,EAJG,OAAA,CAAQ,GAIX;EAAgB,GAAA,EAHb,MAGa,CAAA,MAAA,EAHE,UAGF,CAAA;AAEP,CAAA,GAJT,gBAIuB,CAJN,CAIM,CAAA,CAAA,EAK/B,CAAA,MAPQ,gBAOI,CAAA;AAAsB,UALjB,cAAA,CAKiB;MAAK,MAAA;aAC7B,CAAA,EAAA,MAAA;;AACL,KAFO,sBAEP,CAAA,IAFkC,cAElC,CAAA,GAAA,CAAA,MAAA,EADK,eACL,EAAA,GAA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;oCAIT,qBACC,mBACH,wBACI"}
1
+ {"version":3,"file":"InngestExecution.d.ts","names":[],"sources":["../../../src/components/execution/InngestExecution.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;UA6BiB,gBAAA;;;;;UAEK;;;;;;;;IAFL,KAAA,EAAA,CAIU,UAJM,EAAA,GAIS,UAJT,EAAA,CAAA;EAAA,CAAA;kBAEX,EAAA;IAEK,IAAA,EAEjB,UAFiB;IAAe,UAAA,EAG1B,cAH0B,EAAA;IAEhC,eAAA,EAAA,MAAA;;;;AAeV;;eACc,EAAA;IAEF,EAAA,EARJ,QAQI;IACD,KAAA,EAAQ,MAAA;;;AAEX,KANI,eAAA,GAMJ,QAAiB,MALX,gBAKW,GALQ,QAKR,CAAA;EALQ,IAAA,EAErB,CAFqB;EAOzB,GAAA,EAJG,OAAA,CAAQ,GAIX;EAAgB,GAAA,EAHb,MAGa,CAAA,MAAA,EAHE,UAGF,CAAA;AAEP,CAAA,GAJT,gBAIuB,CAJN,CAIM,CAAA,CAAA,EAK/B,CAAA,MAPQ,gBAOI,CAAA;AAAsB,UALjB,cAAA,CAKiB;MAAK,MAAA;aAC7B,CAAA,EAAA,MAAA;;AACL,KAFO,sBAEP,CAAA,IAFkC,cAElC,CAAA,GAAA,CAAA,MAAA,EADK,eACL,EAAA,GAAA,YAAA,CAAa,CAAb,CAAA;AAAY,KAEL,uBAFK,CAAA,IAEuB,cAFvB,CAAA,GAAA,QAGT,eADI,IACe,CADQ,CAAA,MAAA,CAAA,GAAA,CAAA,MAAA,EACa,CADb,EAAA,GACmB,YADnB,CACgC,CADhC,CAAA,EAAA;AAAK,UAIvB,UAAA,SAAmB,UAJI,CAAA;;;;;SACc,CAAA,EAAA,OAAA,EAAA;EAAY,SAAA,CAAA,EAAA,OAAA;EAGjD;;;SAAmB,CAAA,EAWxB,OAXwB,CAAA,OAAA,CAAA;EAAU,IAAA,CAAA,EAAA,OAAA;AAsB9C;AAMA;;;;;;;AAea,cArBA,iCAAA,GAqBA,gBAAA,CAAA,EAAA;;;;AAyCF,UAxDM,uBAAA,CAwDN;QAED,EAzDA,OAAA,CAAQ,GAyDR;MAxDJ,eAAA,CAAgB,GAkFK;;;;;;;;EA+Bf,YAAA,CAAA,EAAA,MAAA;EAAuB,OAAA,EAAA,OAAA,EAAA;OACxB,EAAA,MAAA;MACN,EAvGG,IAuGH,CAvGQ,OAAA,CAAQ,GAuGhB,EAAA,MAAA,GAAA,OAAA,GAAA,SAAA,GAAA,OAAA,CAAA;EAAiB,SAAA,EAtGT,MAsGS,CAAA,MAAA,EAtGM,UAsGN,CAAA;EAET;;;;;;AAQb;EAAkC,WAAA,CAAA,EAvGlB,MAuGkB,CAAA,MAAA,EAAA;IACvB,SAAA,CAAA,EAAA,OAAA;;qBACA,EAAA,MAAA,EAAA;UAID,EA1GE,QA0GF;qBACC,CAAA,EA1Ga,4BA0Gb;;;;;;;;;;;;;;;;;;;;;;;WA9EA;;UAED;;;;;;;;;;;;;;;;;;;;;;;gBA0BM,UAAA,CAAW;;;;;;wBAOH,UAAA,CAAW;;;;;;;;;;;uBAaZ,SAAS,OAAA,CAAQ,SAAS,OAAA,CAAQ;;;;;;;sCAQnB,aAAa;;KAGvC,uBAAA,aACD,4BACN;cAEQ,gBAAA;qBAGoB;sBAFX;uBAEW;;UAKhB,iBAAA;WACN;WACA,QAAQ;oCAIT,qBACC,mBACH,wBACI"}
@@ -1 +1 @@
1
- {"version":3,"file":"InngestExecution.js","names":["options: InngestExecutionOptions"],"sources":["../../../src/components/execution/InngestExecution.ts"],"sourcesContent":["import Debug, { type Debugger } from \"debug\";\nimport { debugPrefix, ExecutionVersion } from \"../../helpers/consts.ts\";\nimport type { ServerTiming } from \"../../helpers/ServerTiming.ts\";\nimport type { MaybePromise, Simplify } from \"../../helpers/types.ts\";\nimport type {\n Context,\n IncomingOp,\n InternalCheckpointingOptions,\n OutgoingOp,\n StepMode,\n} from \"../../types.ts\";\nimport type { Inngest } from \"../Inngest.ts\";\nimport type { ActionResponse } from \"../InngestCommHandler.ts\";\nimport type { InngestFunction } from \"../InngestFunction.ts\";\nimport type {\n MetadataKind,\n MetadataOpcode,\n MetadataScope,\n} from \"../InngestMetadata.ts\";\nimport type { Middleware } from \"../middleware/middleware.ts\";\n\n// Re-export ExecutionVersion so it's correctly recognized as an enum and not\n// just a type. This can be lost when bundling if we don't re-export it here.\n// See `pnpm run test:dist`.\nexport { ExecutionVersion };\n\n/**\n * The possible results of an execution.\n */\nexport interface ExecutionResults {\n \"function-resolved\": { data: unknown };\n \"step-ran\": { step: OutgoingOp; retriable?: boolean | string };\n \"function-rejected\": { error: unknown; retriable: boolean | string };\n \"steps-found\": { steps: [OutgoingOp, ...OutgoingOp[]] };\n \"step-not-found\": {\n step: OutgoingOp;\n foundSteps: BasicFoundStep[];\n totalFoundSteps: number;\n };\n\n /**\n * Indicates that we need to relinquish control back to Inngest in order to\n * change step modes.\n */\n \"change-mode\": {\n to: StepMode;\n token: string;\n };\n}\n\nexport type ExecutionResult = {\n [K in keyof ExecutionResults]: Simplify<\n {\n type: K;\n ctx: Context.Any;\n ops: Record<string, MemoizedOp>;\n } & ExecutionResults[K]\n >;\n}[keyof ExecutionResults];\n\nexport interface BasicFoundStep {\n id: string;\n displayName?: string;\n}\n\nexport type ExecutionResultHandler<T = ActionResponse> = (\n result: ExecutionResult,\n) => MaybePromise<T>;\n\nexport type ExecutionResultHandlers<T = ActionResponse> = {\n [E in ExecutionResult as E[\"type\"]]: (result: E) => MaybePromise<T>;\n};\n\nexport interface MemoizedOp extends IncomingOp {\n /**\n * If the step has been hit during this run, these will be the arguments\n * passed to it.\n */\n rawArgs?: unknown[];\n fulfilled?: boolean;\n\n /**\n * The promise that has been returned to userland code.\n */\n promise?: Promise<unknown>;\n seen?: boolean;\n}\n\n/**\n * The preferred execution version that will be used by the SDK when handling\n * brand new runs where the Executor is allowing us to choose.\n *\n * Changing this should not ever be a breaking change, as this will only change\n * new runs, not existing ones.\n */\nexport const PREFERRED_ASYNC_EXECUTION_VERSION =\n ExecutionVersion.V2 satisfies ExecutionVersion;\n\n/**\n * Options for creating a new {@link InngestExecution} instance.\n */\nexport interface InngestExecutionOptions {\n client: Inngest.Any;\n fn: InngestFunction.Any;\n\n /**\n * The UUID that represents this function in Inngest.\n *\n * This is used to reference the function during async checkpointing, when we\n * know the function/run already exists and just wish to reference it\n * directly.\n */\n internalFnId?: string;\n reqArgs: unknown[];\n runId: string;\n data: Omit<Context.Any, \"step\" | \"group\" | \"publish\" | \"defer\">;\n stepState: Record<string, MemoizedOp>;\n\n /**\n * A map of hashed defer step IDs to their backend-side metadata\n * (e.g. `{ abortable: true }`). Defer ops are not steps in the\n * memoization sense — they don't produce results — but the backend\n * tracks which ones it has already received so the SDK can avoid\n * re-emitting them on replay.\n */\n priorDefers?: Record<string, unknown>;\n\n stepCompletionOrder: string[];\n stepMode: StepMode;\n checkpointingConfig?: InternalCheckpointingOptions;\n\n /**\n * If this execution is being run from a queue job, this will be an identifier\n * used to reference this execution in Inngest. SDKs are expected to parrot\n * this back in some responses to correctly attribute actions to this queue\n * item.\n */\n queueItemId?: string;\n\n /**\n * Unique identifier for each execution request\n */\n requestId?: string;\n\n /**\n * Incrementing ID used to denote the generation in which this job was queued\n */\n generationId?: number;\n\n /**\n * Time the SDK starts handling an execution request. Format is unix millis.\n */\n requestStartedAt?: number;\n\n /**\n * Headers to be sent with any request to Inngest during this execution.\n */\n headers: Record<string, string>;\n requestedRunStep?: string;\n timer?: ServerTiming;\n /**\n * Which handler variant is being executed. `\"failure\"` skips\n * trigger-schema validation and resolves `onFailure` instead of the\n * main handler. `\"defer\"` marks the fn as a standalone defer function\n * (created via `createDefer`); incoming event data is validated\n * against the defer function's schema.\n *\n * @default \"main\"\n */\n handlerKind?: \"main\" | \"failure\" | \"defer\";\n\n /**\n * Whether this execution is part of a Durable Endpoint flow. Could be either\n * sync mode (request not from Inngest) or async mode (request from Inngest).\n *\n * @default false\n */\n isDurableEndpoint?: boolean;\n\n disableImmediateExecution?: boolean;\n\n /**\n * Information about the incoming HTTP request that triggered this execution.\n * Used by middleware `wrapRequest` hooks.\n */\n requestInfo?: Middleware.Request;\n\n /**\n * Pre-created middleware instances to use for this execution. When provided,\n * the execution will use these instead of instantiating new ones from the\n * client. This ensures `wrapRequest` and other hooks share state on `this`.\n */\n middlewareInstances?: Middleware.BaseMiddleware[];\n\n /**\n * Whether the client accepts SSE (`Accept: text/event-stream`). When true,\n * the execution engine may deliver the result as an SSE stream even if\n * `stream.push()` was not called.\n */\n acceptsSse?: boolean;\n\n /**\n * Provide the ability to transform the context passed to the function before\n * the execution starts.\n */\n transformCtx?: (ctx: Readonly<Context.Any>) => Context.Any;\n\n /**\n * A hook that is called to create an {@link ActionResponse} from the returned\n * value of an execution.\n *\n * This is required for checkpointing executions.\n */\n createResponse?: (data: unknown) => MaybePromise<ActionResponse>;\n}\n\nexport type InngestExecutionFactory = (\n options: InngestExecutionOptions,\n) => IInngestExecution;\n\nexport class InngestExecution {\n protected devDebug: Debugger;\n\n constructor(protected options: InngestExecutionOptions) {\n this.devDebug = Debug(`${debugPrefix}:${this.options.runId}`);\n }\n}\n\nexport interface IInngestExecution {\n version: ExecutionVersion;\n start(): Promise<ExecutionResult>;\n\n addMetadata(\n stepId: string,\n kind: MetadataKind,\n scope: MetadataScope,\n op: MetadataOpcode,\n values: Record<string, unknown>,\n ): boolean;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+FA,MAAa,oCACX,iBAAiB;AA4HnB,IAAa,mBAAb,MAA8B;CAC5B,AAAU;CAEV,YAAY,AAAUA,SAAkC;EAAlC;AACpB,OAAK,WAAW,MAAM,GAAG,YAAY,GAAG,KAAK,QAAQ,QAAQ"}
1
+ {"version":3,"file":"InngestExecution.js","names":["options: InngestExecutionOptions"],"sources":["../../../src/components/execution/InngestExecution.ts"],"sourcesContent":["import Debug, { type Debugger } from \"debug\";\nimport { debugPrefix, ExecutionVersion } from \"../../helpers/consts.ts\";\nimport type { ServerTiming } from \"../../helpers/ServerTiming.ts\";\nimport type { MaybePromise, Simplify } from \"../../helpers/types.ts\";\nimport type {\n Context,\n IncomingOp,\n InternalCheckpointingOptions,\n OutgoingOp,\n StepMode,\n} from \"../../types.ts\";\nimport type { Inngest } from \"../Inngest.ts\";\nimport type { ActionResponse } from \"../InngestCommHandler.ts\";\nimport type { InngestFunction } from \"../InngestFunction.ts\";\nimport type {\n MetadataKind,\n MetadataOpcode,\n MetadataScope,\n} from \"../InngestMetadata.ts\";\nimport type { Middleware } from \"../middleware/middleware.ts\";\n\n// Re-export ExecutionVersion so it's correctly recognized as an enum and not\n// just a type. This can be lost when bundling if we don't re-export it here.\n// See `pnpm run test:dist`.\nexport { ExecutionVersion };\n\n/**\n * The possible results of an execution.\n */\nexport interface ExecutionResults {\n \"function-resolved\": { data: unknown };\n \"step-ran\": { step: OutgoingOp; retriable?: boolean | string };\n \"function-rejected\": { error: unknown; retriable: boolean | string };\n \"steps-found\": { steps: [OutgoingOp, ...OutgoingOp[]] };\n \"step-not-found\": {\n step: OutgoingOp;\n foundSteps: BasicFoundStep[];\n totalFoundSteps: number;\n };\n\n /**\n * Indicates that we need to relinquish control back to Inngest in order to\n * change step modes.\n */\n \"change-mode\": {\n to: StepMode;\n token: string;\n };\n}\n\nexport type ExecutionResult = {\n [K in keyof ExecutionResults]: Simplify<\n {\n type: K;\n ctx: Context.Any;\n ops: Record<string, MemoizedOp>;\n } & ExecutionResults[K]\n >;\n}[keyof ExecutionResults];\n\nexport interface BasicFoundStep {\n id: string;\n displayName?: string;\n}\n\nexport type ExecutionResultHandler<T = ActionResponse> = (\n result: ExecutionResult,\n) => MaybePromise<T>;\n\nexport type ExecutionResultHandlers<T = ActionResponse> = {\n [E in ExecutionResult as E[\"type\"]]: (result: E) => MaybePromise<T>;\n};\n\nexport interface MemoizedOp extends IncomingOp {\n /**\n * If the step has been hit during this run, these will be the arguments\n * passed to it.\n */\n rawArgs?: unknown[];\n fulfilled?: boolean;\n\n /**\n * The promise that has been returned to userland code.\n */\n promise?: Promise<unknown>;\n seen?: boolean;\n}\n\n/**\n * The preferred execution version that will be used by the SDK when handling\n * brand new runs where the Executor is allowing us to choose.\n *\n * Changing this should not ever be a breaking change, as this will only change\n * new runs, not existing ones.\n */\nexport const PREFERRED_ASYNC_EXECUTION_VERSION =\n ExecutionVersion.V2 satisfies ExecutionVersion;\n\n/**\n * Options for creating a new {@link InngestExecution} instance.\n */\nexport interface InngestExecutionOptions {\n client: Inngest.Any;\n fn: InngestFunction.Any;\n\n /**\n * The UUID that represents this function in Inngest.\n *\n * This is used to reference the function during async checkpointing, when we\n * know the function/run already exists and just wish to reference it\n * directly.\n */\n internalFnId?: string;\n reqArgs: unknown[];\n runId: string;\n data: Omit<Context.Any, \"step\" | \"group\" | \"publish\" | \"defer\">;\n stepState: Record<string, MemoizedOp>;\n\n /**\n * A map of hashed defer step IDs to their backend-side metadata\n * (e.g. `{ abortable: true }`). Defer ops are not steps in the\n * memoization sense — they don't produce results — but the backend\n * tracks which ones it has already received so the SDK can avoid\n * re-emitting them on replay.\n */\n priorDefers?: Record<string, { abortable?: boolean }>;\n\n stepCompletionOrder: string[];\n stepMode: StepMode;\n checkpointingConfig?: InternalCheckpointingOptions;\n\n /**\n * If this execution is being run from a queue job, this will be an identifier\n * used to reference this execution in Inngest. SDKs are expected to parrot\n * this back in some responses to correctly attribute actions to this queue\n * item.\n */\n queueItemId?: string;\n\n /**\n * Unique identifier for each execution request\n */\n requestId?: string;\n\n /**\n * Incrementing ID used to denote the generation in which this job was queued\n */\n generationId?: number;\n\n /**\n * Time the SDK starts handling an execution request. Format is unix millis.\n */\n requestStartedAt?: number;\n\n /**\n * Headers to be sent with any request to Inngest during this execution.\n */\n headers: Record<string, string>;\n requestedRunStep?: string;\n timer?: ServerTiming;\n /**\n * Which handler variant is being executed. `\"failure\"` skips\n * trigger-schema validation and resolves `onFailure` instead of the\n * main handler. `\"defer\"` marks the fn as a standalone defer function\n * (created via `createDefer`); incoming event data is validated\n * against the defer function's schema.\n *\n * @default \"main\"\n */\n handlerKind?: \"main\" | \"failure\" | \"defer\";\n\n /**\n * Whether this execution is part of a Durable Endpoint flow. Could be either\n * sync mode (request not from Inngest) or async mode (request from Inngest).\n *\n * @default false\n */\n isDurableEndpoint?: boolean;\n\n disableImmediateExecution?: boolean;\n\n /**\n * Information about the incoming HTTP request that triggered this execution.\n * Used by middleware `wrapRequest` hooks.\n */\n requestInfo?: Middleware.Request;\n\n /**\n * Pre-created middleware instances to use for this execution. When provided,\n * the execution will use these instead of instantiating new ones from the\n * client. This ensures `wrapRequest` and other hooks share state on `this`.\n */\n middlewareInstances?: Middleware.BaseMiddleware[];\n\n /**\n * Whether the client accepts SSE (`Accept: text/event-stream`). When true,\n * the execution engine may deliver the result as an SSE stream even if\n * `stream.push()` was not called.\n */\n acceptsSse?: boolean;\n\n /**\n * Provide the ability to transform the context passed to the function before\n * the execution starts.\n */\n transformCtx?: (ctx: Readonly<Context.Any>) => Context.Any;\n\n /**\n * A hook that is called to create an {@link ActionResponse} from the returned\n * value of an execution.\n *\n * This is required for checkpointing executions.\n */\n createResponse?: (data: unknown) => MaybePromise<ActionResponse>;\n}\n\nexport type InngestExecutionFactory = (\n options: InngestExecutionOptions,\n) => IInngestExecution;\n\nexport class InngestExecution {\n protected devDebug: Debugger;\n\n constructor(protected options: InngestExecutionOptions) {\n this.devDebug = Debug(`${debugPrefix}:${this.options.runId}`);\n }\n}\n\nexport interface IInngestExecution {\n version: ExecutionVersion;\n start(): Promise<ExecutionResult>;\n\n addMetadata(\n stepId: string,\n kind: MetadataKind,\n scope: MetadataScope,\n op: MetadataOpcode,\n values: Record<string, unknown>,\n ): boolean;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+FA,MAAa,oCACX,iBAAiB;AA4HnB,IAAa,mBAAb,MAA8B;CAC5B,AAAU;CAEV,YAAY,AAAUA,SAAkC;EAAlC;AACpB,OAAK,WAAW,MAAM,GAAG,YAAY,GAAG,KAAK,QAAQ,QAAQ"}
@@ -1489,45 +1489,48 @@ var InngestExecutionEngine = class extends require_InngestExecution.InngestExecu
1489
1489
  return (idOrOptions, { function: deferFn, data, experiment }) => {
1490
1490
  const log = this.options.client[require_Inngest.internalLoggerSymbol];
1491
1491
  const runId = this.fnArg.runId;
1492
+ const noopHandle = { abort: () => {} };
1492
1493
  try {
1493
1494
  if (!require_marker.isDeferredFunction(deferFn)) {
1494
1495
  log.error({ runId }, "defer skipped: function not created via createDefer");
1495
- return;
1496
+ return noopHandle;
1496
1497
  }
1497
1498
  const { schema } = deferFn;
1498
1499
  const deferFnSlug = deferFn.id(this.options.client.id);
1500
+ const stepOptions = require_InngestStepTools.getStepOptions(idOrOptions);
1501
+ const hashedId = _internals.hashId(stepOptions.id);
1499
1502
  let input = data;
1500
1503
  if (schema) {
1501
1504
  const result = schema["~standard"].validate(data);
1502
1505
  if (result instanceof Promise) {
1503
1506
  log.error({ runId }, "defer() requires a synchronous schema validator. The defer call was skipped.");
1504
- return;
1507
+ return noopHandle;
1505
1508
  }
1506
1509
  if (result.issues) {
1507
1510
  log.error({
1508
1511
  runId,
1509
1512
  issues: result.issues
1510
1513
  }, "defer skipped: schema validation failed");
1511
- return;
1514
+ return noopHandle;
1512
1515
  }
1513
1516
  input = result.value ?? data;
1514
1517
  }
1515
1518
  stepHandler({
1516
- args: [idOrOptions, experiment && require_types$1.isRecord(input) ? {
1519
+ args: [stepOptions, experiment && require_types$1.isRecord(input) ? {
1517
1520
  ...input,
1518
1521
  [require_consts.deferExperimentKey]: experiment
1519
1522
  } : input],
1520
- matchOp: (stepOptions, inputArg) => ({
1521
- id: stepOptions.id,
1523
+ matchOp: (stepOptions$1, inputArg) => ({
1524
+ id: stepOptions$1.id,
1522
1525
  mode: require_types.StepMode.Sync,
1523
1526
  op: require_types.StepOpCode.DeferAdd,
1524
- name: stepOptions.name ?? stepOptions.id,
1525
- displayName: stepOptions.name ?? stepOptions.id,
1527
+ name: stepOptions$1.name ?? stepOptions$1.id,
1528
+ displayName: stepOptions$1.name ?? stepOptions$1.id,
1526
1529
  opts: {
1527
1530
  fn_slug: deferFnSlug,
1528
1531
  input: inputArg
1529
1532
  },
1530
- userland: { id: stepOptions.id }
1533
+ userland: { id: stepOptions$1.id }
1531
1534
  })
1532
1535
  }).catch((err) => {
1533
1536
  log.error({
@@ -1535,11 +1538,48 @@ var InngestExecutionEngine = class extends require_InngestExecution.InngestExecu
1535
1538
  err
1536
1539
  }, "defer skipped: unexpected error");
1537
1540
  });
1541
+ return { abort: () => {
1542
+ try {
1543
+ if (this.state.priorDefers[hashedId]?.abortable === false) return;
1544
+ const abortId = `${hashedId}:abort`;
1545
+ if (this.state.lazyOps.hasId(_internals.hashId(abortId))) return;
1546
+ stepHandler({
1547
+ args: [{
1548
+ id: abortId,
1549
+ name: stepOptions.name
1550
+ }, null],
1551
+ matchOp: (abortStepOptions) => ({
1552
+ id: abortStepOptions.id,
1553
+ mode: require_types.StepMode.Sync,
1554
+ op: require_types.StepOpCode.DeferAbort,
1555
+ name: stepOptions.name ?? stepOptions.id,
1556
+ displayName: stepOptions.name ?? stepOptions.id,
1557
+ opts: {
1558
+ target_hashed_id: hashedId,
1559
+ fn_slug: deferFnSlug,
1560
+ id: stepOptions.id
1561
+ },
1562
+ userland: { id: stepOptions.id }
1563
+ })
1564
+ }).catch((err) => {
1565
+ log.error({
1566
+ runId,
1567
+ err
1568
+ }, "defer abort skipped: unexpected error");
1569
+ });
1570
+ } catch (err) {
1571
+ log.error({
1572
+ runId,
1573
+ err
1574
+ }, "defer abort skipped: unexpected error");
1575
+ }
1576
+ } };
1538
1577
  } catch (err) {
1539
1578
  log.error({
1540
1579
  runId,
1541
1580
  err
1542
1581
  }, "defer skipped: unexpected error");
1582
+ return noopHandle;
1543
1583
  }
1544
1584
  };
1545
1585
  }