@mastra/inngest 1.11.3-alpha.0 → 1.11.3-alpha.1

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.
package/dist/connect.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("./src-D7lwaeuu.cjs");
2
+ const require_src = require("./src-5A0aFcD7.cjs");
3
3
  exports.connect = require_src.connect;
package/dist/connect.js CHANGED
@@ -1 +1 @@
1
- export { i as connect } from "./src-BfHlZT-M.js";
1
+ export { i as connect } from "./src-CFtk0_CD.js";
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("./src-D7lwaeuu.cjs");
2
+ const require_src = require("./src-5A0aFcD7.cjs");
3
3
  exports.InngestExecutionEngine = require_src.InngestExecutionEngine;
4
4
  exports.InngestPubSub = require_src.InngestPubSub;
5
5
  exports.InngestRun = require_src.InngestRun;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { m as InngestExecutionEngine, f as InngestPubSub, d as InngestRun, u as InngestWorkflow, p as OVERSIZED_EVENT_CHUNK_TYPE, r as _compatibilityCheck, i as connect, s as createInngestAgent, l as createInngestDurableAgenticWorkflow, a as createServe, t as createStep, n as init, c as isInngestAgent, o as serve } from "./src-BfHlZT-M.js";
1
+ export { m as InngestExecutionEngine, f as InngestPubSub, d as InngestRun, u as InngestWorkflow, p as OVERSIZED_EVENT_CHUNK_TYPE, r as _compatibilityCheck, i as connect, s as createInngestAgent, l as createInngestDurableAgenticWorkflow, a as createServe, t as createStep, n as init, c as isInngestAgent, o as serve } from "./src-CFtk0_CD.js";
@@ -2061,6 +2061,43 @@ var InngestWorkflow = class extends _mastra_core_workflows.Workflow {
2061
2061
  });
2062
2062
  return run;
2063
2063
  }
2064
+ /**
2065
+ * Records a run Inngest gave up on as failed. Only a row still marked live is
2066
+ * rewritten: a run that failed in its own code already wrote a richer terminal
2067
+ * snapshot in finalize, and a suspended row stays resumable.
2068
+ */
2069
+ async #markRunFailed(runId, error) {
2070
+ const workflowsStore = await this.#mastra?.getStorage()?.getStore("workflows");
2071
+ if (!workflowsStore) return;
2072
+ const run = await workflowsStore.getWorkflowRunById({
2073
+ runId,
2074
+ workflowName: this.id
2075
+ });
2076
+ const snapshot = typeof run?.snapshot === "string" ? void 0 : run?.snapshot;
2077
+ if (!snapshot || ![
2078
+ "running",
2079
+ "pending",
2080
+ "waiting"
2081
+ ].includes(snapshot.status)) return;
2082
+ await workflowsStore.persistWorkflowSnapshot({
2083
+ workflowName: this.id,
2084
+ runId,
2085
+ resourceId: run?.resourceId,
2086
+ expectedStatus: [
2087
+ "running",
2088
+ "pending",
2089
+ "waiting"
2090
+ ],
2091
+ snapshot: {
2092
+ ...snapshot,
2093
+ status: "failed",
2094
+ activePaths: [],
2095
+ activeStepsPath: {},
2096
+ error: (0, _mastra_core_error.getErrorFromUnknown)(error, { fallbackMessage: "Inngest run failed" }),
2097
+ timestamp: Date.now()
2098
+ }
2099
+ });
2100
+ }
2064
2101
  createCronFunction() {
2065
2102
  if (this.cronFunction) return this.cronFunction;
2066
2103
  this.cronFunction = this.inngest.createFunction({
@@ -2096,6 +2133,11 @@ var InngestWorkflow = class extends _mastra_core_workflows.Workflow {
2096
2133
  event: `cancel.workflow.${this.id}`,
2097
2134
  match: "data.runId"
2098
2135
  }],
2136
+ onFailure: async ({ event, error }) => {
2137
+ const original = event.data?.event?.data;
2138
+ if (typeof original?.runId !== "string" || original.resume?.claim) return;
2139
+ await this.#markRunFailed(original.runId, error);
2140
+ },
2099
2141
  triggers: { event: `workflow.${this.id}` },
2100
2142
  ...this.flowControlConfig
2101
2143
  },
@@ -5248,4 +5290,4 @@ Object.defineProperty(exports, "serve", {
5248
5290
  }
5249
5291
  });
5250
5292
 
5251
- //# sourceMappingURL=src-D7lwaeuu.cjs.map
5293
+ //# sourceMappingURL=src-5A0aFcD7.cjs.map