@mastra/inngest 1.11.3-alpha.0 → 1.11.3

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.
@@ -2039,6 +2039,43 @@ var InngestWorkflow = class extends Workflow {
2039
2039
  });
2040
2040
  return run;
2041
2041
  }
2042
+ /**
2043
+ * Records a run Inngest gave up on as failed. Only a row still marked live is
2044
+ * rewritten: a run that failed in its own code already wrote a richer terminal
2045
+ * snapshot in finalize, and a suspended row stays resumable.
2046
+ */
2047
+ async #markRunFailed(runId, error) {
2048
+ const workflowsStore = await this.#mastra?.getStorage()?.getStore("workflows");
2049
+ if (!workflowsStore) return;
2050
+ const run = await workflowsStore.getWorkflowRunById({
2051
+ runId,
2052
+ workflowName: this.id
2053
+ });
2054
+ const snapshot = typeof run?.snapshot === "string" ? void 0 : run?.snapshot;
2055
+ if (!snapshot || ![
2056
+ "running",
2057
+ "pending",
2058
+ "waiting"
2059
+ ].includes(snapshot.status)) return;
2060
+ await workflowsStore.persistWorkflowSnapshot({
2061
+ workflowName: this.id,
2062
+ runId,
2063
+ resourceId: run?.resourceId,
2064
+ expectedStatus: [
2065
+ "running",
2066
+ "pending",
2067
+ "waiting"
2068
+ ],
2069
+ snapshot: {
2070
+ ...snapshot,
2071
+ status: "failed",
2072
+ activePaths: [],
2073
+ activeStepsPath: {},
2074
+ error: getErrorFromUnknown(error, { fallbackMessage: "Inngest run failed" }),
2075
+ timestamp: Date.now()
2076
+ }
2077
+ });
2078
+ }
2042
2079
  createCronFunction() {
2043
2080
  if (this.cronFunction) return this.cronFunction;
2044
2081
  this.cronFunction = this.inngest.createFunction({
@@ -2074,6 +2111,11 @@ var InngestWorkflow = class extends Workflow {
2074
2111
  event: `cancel.workflow.${this.id}`,
2075
2112
  match: "data.runId"
2076
2113
  }],
2114
+ onFailure: async ({ event, error }) => {
2115
+ const original = event.data?.event?.data;
2116
+ if (typeof original?.runId !== "string" || original.resume?.claim) return;
2117
+ await this.#markRunFailed(original.runId, error);
2118
+ },
2077
2119
  triggers: { event: `workflow.${this.id}` },
2078
2120
  ...this.flowControlConfig
2079
2121
  },
@@ -5143,4 +5185,4 @@ function init(inngest) {
5143
5185
  }
5144
5186
  export { createServe as a, isInngestAgent as c, InngestRun as d, InngestPubSub as f, connect as i, createInngestDurableAgenticWorkflow as l, InngestExecutionEngine as m, init as n, serve$1 as o, OVERSIZED_EVENT_CHUNK_TYPE as p, _compatibilityCheck as r, createInngestAgent as s, createStep as t, InngestWorkflow as u };
5145
5187
 
5146
- //# sourceMappingURL=src-BfHlZT-M.js.map
5188
+ //# sourceMappingURL=src-CFtk0_CD.js.map