@mastra/inngest 1.1.1 → 1.1.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @mastra/inngest
2
2
 
3
+ ## 1.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Flush observability after Inngest workflow finalize step to ensure span export promises resolve before the function completes. Fixes #13388 where fire-and-forget export promises were abandoned in durable execution contexts. ([#13717](https://github.com/mastra-ai/mastra/pull/13717))
8
+
9
+ - Fixed observability flush to run on all code paths, including when the finalize step throws an error. Previously, if the workflow failed inside step.run, the flush call was skipped because it was placed after the await. ([#13721](https://github.com/mastra-ai/mastra/pull/13721))
10
+
11
+ - Updated dependencies [[`504fc8b`](https://github.com/mastra-ai/mastra/commit/504fc8b9d0ddab717577ad3bf9c95ea4bd5377bd), [`f9c150b`](https://github.com/mastra-ai/mastra/commit/f9c150b7595ad05ad9cc9a11098e2944361e8c22), [`88de7e8`](https://github.com/mastra-ai/mastra/commit/88de7e8dfe4b7e1951a9e441bb33136e705ce24e), [`edee4b3`](https://github.com/mastra-ai/mastra/commit/edee4b37dff0af515fc7cc0e8d71ee39e6a762f0), [`3790c75`](https://github.com/mastra-ai/mastra/commit/3790c7578cc6a47d854eb12d89e6b1912867fe29), [`e7a235b`](https://github.com/mastra-ai/mastra/commit/e7a235be6472e0c870ed6c791ddb17c492dc188b), [`d51d298`](https://github.com/mastra-ai/mastra/commit/d51d298953967aab1f58ec965b644d109214f085), [`6dbeeb9`](https://github.com/mastra-ai/mastra/commit/6dbeeb94a8b1eebb727300d1a98961f882180794), [`d5f0d8d`](https://github.com/mastra-ai/mastra/commit/d5f0d8d6a03e515ddaa9b5da19b7e44b8357b07b), [`09c3b18`](https://github.com/mastra-ai/mastra/commit/09c3b1802ff14e243a8a8baea327440bc8cc2e32), [`b896379`](https://github.com/mastra-ai/mastra/commit/b8963791c6afa79484645fcec596a201f936b9a2), [`85c84eb`](https://github.com/mastra-ai/mastra/commit/85c84ebb78aebfcba9d209c8e152b16d7a00cb71), [`a89272a`](https://github.com/mastra-ai/mastra/commit/a89272a5d71939b9fcd284e6a6dc1dd091a6bdcf), [`ee9c8df`](https://github.com/mastra-ai/mastra/commit/ee9c8df644f19d055af5f496bf4942705f5a47b7), [`77b4a25`](https://github.com/mastra-ai/mastra/commit/77b4a254e51907f8ff3a3ba95596a18e93ae4b35), [`276246e`](https://github.com/mastra-ai/mastra/commit/276246e0b9066a1ea48bbc70df84dbe528daaf99), [`08ecfdb`](https://github.com/mastra-ai/mastra/commit/08ecfdbdad6fb8285deef86a034bdf4a6047cfca), [`d5f628c`](https://github.com/mastra-ai/mastra/commit/d5f628ca86c6f6f3ff1035d52f635df32dd81cab), [`524c0f3`](https://github.com/mastra-ai/mastra/commit/524c0f3c434c3d9d18f66338dcef383d6161b59c), [`c18a0e9`](https://github.com/mastra-ai/mastra/commit/c18a0e9cef1e4ca004b2963d35e4cfc031971eac), [`4bd21ea`](https://github.com/mastra-ai/mastra/commit/4bd21ea43d44d0a0427414fc047577f9f0aa3bec), [`115a7a4`](https://github.com/mastra-ai/mastra/commit/115a7a47db5e9896fec12ae6507501adb9ec89bf), [`22a48ae`](https://github.com/mastra-ai/mastra/commit/22a48ae2513eb54d8d79dad361fddbca97a155e8), [`3c6ef79`](https://github.com/mastra-ai/mastra/commit/3c6ef798481e00d6d22563be2de98818fd4dd5e0), [`9311c17`](https://github.com/mastra-ai/mastra/commit/9311c17d7a0640d9c4da2e71b814dc67c57c6369), [`7edf78f`](https://github.com/mastra-ai/mastra/commit/7edf78f80422c43e84585f08ba11df0d4d0b73c5), [`1c4221c`](https://github.com/mastra-ai/mastra/commit/1c4221cf6032ec98d0e094d4ee11da3e48490d96), [`d25b9ea`](https://github.com/mastra-ai/mastra/commit/d25b9eabd400167255a97b690ffbc4ee4097ded5), [`fe1ce5c`](https://github.com/mastra-ai/mastra/commit/fe1ce5c9211c03d561606fda95cbfe7df1d9a9b5), [`b03c0e0`](https://github.com/mastra-ai/mastra/commit/b03c0e0389a799523929a458b0509c9e4244d562), [`0a8366b`](https://github.com/mastra-ai/mastra/commit/0a8366b0a692fcdde56c4d526e4cf03c502ae4ac), [`85664e9`](https://github.com/mastra-ai/mastra/commit/85664e9fd857320fbc245e301f764f45f66f32a3), [`bc79650`](https://github.com/mastra-ai/mastra/commit/bc796500c6e0334faa158a96077e3fb332274869), [`9257d01`](https://github.com/mastra-ai/mastra/commit/9257d01d1366d81f84c582fe02b5e200cf9621f4), [`3a3a59e`](https://github.com/mastra-ai/mastra/commit/3a3a59e8ffaa6a985fe3d9a126a3f5ade11a6724), [`3108d4e`](https://github.com/mastra-ai/mastra/commit/3108d4e649c9fddbf03253a6feeb388a5fa9fa5a), [`0c33b2c`](https://github.com/mastra-ai/mastra/commit/0c33b2c9db537f815e1c59e2c898ffce2e395a79), [`191e5bd`](https://github.com/mastra-ai/mastra/commit/191e5bd29b82f5bda35243945790da7bc7b695c2), [`f77cd94`](https://github.com/mastra-ai/mastra/commit/f77cd94c44eabed490384e7d19232a865e13214c), [`e8135c7`](https://github.com/mastra-ai/mastra/commit/e8135c7e300dac5040670eec7eab896ac6092e30), [`daca48f`](https://github.com/mastra-ai/mastra/commit/daca48f0fb17b7ae0b62a2ac40cf0e491b2fd0b7), [`257d14f`](https://github.com/mastra-ai/mastra/commit/257d14faca5931f2e4186fc165b6f0b1f915deee), [`352f25d`](https://github.com/mastra-ai/mastra/commit/352f25da316b24cdd5b410fd8dddf6a8b763da2a), [`93477d0`](https://github.com/mastra-ai/mastra/commit/93477d0769b8a13ea5ed73d508d967fb23eaeed9), [`31c78b3`](https://github.com/mastra-ai/mastra/commit/31c78b3eb28f58a8017f1dcc795c33214d87feac), [`0bc0720`](https://github.com/mastra-ai/mastra/commit/0bc07201095791858087cc56f353fcd65e87ab54), [`36516ac`](https://github.com/mastra-ai/mastra/commit/36516aca1021cbeb42e74751b46a2614101f37c8), [`e947652`](https://github.com/mastra-ai/mastra/commit/e9476527fdecb4449e54570e80dfaf8466901254), [`3c6ef79`](https://github.com/mastra-ai/mastra/commit/3c6ef798481e00d6d22563be2de98818fd4dd5e0), [`9257d01`](https://github.com/mastra-ai/mastra/commit/9257d01d1366d81f84c582fe02b5e200cf9621f4), [`ec248f6`](https://github.com/mastra-ai/mastra/commit/ec248f6b56e8a037c066c49b2178e2507471d988)]:
12
+ - @mastra/core@1.9.0
13
+
14
+ ## 1.1.2-alpha.0
15
+
16
+ ### Patch Changes
17
+
18
+ - Flush observability after Inngest workflow finalize step to ensure span export promises resolve before the function completes. Fixes #13388 where fire-and-forget export promises were abandoned in durable execution contexts. ([#13717](https://github.com/mastra-ai/mastra/pull/13717))
19
+
20
+ - Fixed observability flush to run on all code paths, including when the finalize step throws an error. Previously, if the workflow failed inside step.run, the flush call was skipped because it was placed after the await. ([#13721](https://github.com/mastra-ai/mastra/pull/13721))
21
+
22
+ - Updated dependencies [[`504fc8b`](https://github.com/mastra-ai/mastra/commit/504fc8b9d0ddab717577ad3bf9c95ea4bd5377bd), [`f9c150b`](https://github.com/mastra-ai/mastra/commit/f9c150b7595ad05ad9cc9a11098e2944361e8c22), [`88de7e8`](https://github.com/mastra-ai/mastra/commit/88de7e8dfe4b7e1951a9e441bb33136e705ce24e), [`edee4b3`](https://github.com/mastra-ai/mastra/commit/edee4b37dff0af515fc7cc0e8d71ee39e6a762f0), [`3790c75`](https://github.com/mastra-ai/mastra/commit/3790c7578cc6a47d854eb12d89e6b1912867fe29), [`e7a235b`](https://github.com/mastra-ai/mastra/commit/e7a235be6472e0c870ed6c791ddb17c492dc188b), [`d51d298`](https://github.com/mastra-ai/mastra/commit/d51d298953967aab1f58ec965b644d109214f085), [`6dbeeb9`](https://github.com/mastra-ai/mastra/commit/6dbeeb94a8b1eebb727300d1a98961f882180794), [`d5f0d8d`](https://github.com/mastra-ai/mastra/commit/d5f0d8d6a03e515ddaa9b5da19b7e44b8357b07b), [`09c3b18`](https://github.com/mastra-ai/mastra/commit/09c3b1802ff14e243a8a8baea327440bc8cc2e32), [`b896379`](https://github.com/mastra-ai/mastra/commit/b8963791c6afa79484645fcec596a201f936b9a2), [`85c84eb`](https://github.com/mastra-ai/mastra/commit/85c84ebb78aebfcba9d209c8e152b16d7a00cb71), [`a89272a`](https://github.com/mastra-ai/mastra/commit/a89272a5d71939b9fcd284e6a6dc1dd091a6bdcf), [`ee9c8df`](https://github.com/mastra-ai/mastra/commit/ee9c8df644f19d055af5f496bf4942705f5a47b7), [`77b4a25`](https://github.com/mastra-ai/mastra/commit/77b4a254e51907f8ff3a3ba95596a18e93ae4b35), [`276246e`](https://github.com/mastra-ai/mastra/commit/276246e0b9066a1ea48bbc70df84dbe528daaf99), [`08ecfdb`](https://github.com/mastra-ai/mastra/commit/08ecfdbdad6fb8285deef86a034bdf4a6047cfca), [`d5f628c`](https://github.com/mastra-ai/mastra/commit/d5f628ca86c6f6f3ff1035d52f635df32dd81cab), [`524c0f3`](https://github.com/mastra-ai/mastra/commit/524c0f3c434c3d9d18f66338dcef383d6161b59c), [`c18a0e9`](https://github.com/mastra-ai/mastra/commit/c18a0e9cef1e4ca004b2963d35e4cfc031971eac), [`4bd21ea`](https://github.com/mastra-ai/mastra/commit/4bd21ea43d44d0a0427414fc047577f9f0aa3bec), [`115a7a4`](https://github.com/mastra-ai/mastra/commit/115a7a47db5e9896fec12ae6507501adb9ec89bf), [`22a48ae`](https://github.com/mastra-ai/mastra/commit/22a48ae2513eb54d8d79dad361fddbca97a155e8), [`3c6ef79`](https://github.com/mastra-ai/mastra/commit/3c6ef798481e00d6d22563be2de98818fd4dd5e0), [`9311c17`](https://github.com/mastra-ai/mastra/commit/9311c17d7a0640d9c4da2e71b814dc67c57c6369), [`7edf78f`](https://github.com/mastra-ai/mastra/commit/7edf78f80422c43e84585f08ba11df0d4d0b73c5), [`1c4221c`](https://github.com/mastra-ai/mastra/commit/1c4221cf6032ec98d0e094d4ee11da3e48490d96), [`d25b9ea`](https://github.com/mastra-ai/mastra/commit/d25b9eabd400167255a97b690ffbc4ee4097ded5), [`fe1ce5c`](https://github.com/mastra-ai/mastra/commit/fe1ce5c9211c03d561606fda95cbfe7df1d9a9b5), [`b03c0e0`](https://github.com/mastra-ai/mastra/commit/b03c0e0389a799523929a458b0509c9e4244d562), [`0a8366b`](https://github.com/mastra-ai/mastra/commit/0a8366b0a692fcdde56c4d526e4cf03c502ae4ac), [`85664e9`](https://github.com/mastra-ai/mastra/commit/85664e9fd857320fbc245e301f764f45f66f32a3), [`bc79650`](https://github.com/mastra-ai/mastra/commit/bc796500c6e0334faa158a96077e3fb332274869), [`9257d01`](https://github.com/mastra-ai/mastra/commit/9257d01d1366d81f84c582fe02b5e200cf9621f4), [`3a3a59e`](https://github.com/mastra-ai/mastra/commit/3a3a59e8ffaa6a985fe3d9a126a3f5ade11a6724), [`3108d4e`](https://github.com/mastra-ai/mastra/commit/3108d4e649c9fddbf03253a6feeb388a5fa9fa5a), [`0c33b2c`](https://github.com/mastra-ai/mastra/commit/0c33b2c9db537f815e1c59e2c898ffce2e395a79), [`191e5bd`](https://github.com/mastra-ai/mastra/commit/191e5bd29b82f5bda35243945790da7bc7b695c2), [`f77cd94`](https://github.com/mastra-ai/mastra/commit/f77cd94c44eabed490384e7d19232a865e13214c), [`e8135c7`](https://github.com/mastra-ai/mastra/commit/e8135c7e300dac5040670eec7eab896ac6092e30), [`daca48f`](https://github.com/mastra-ai/mastra/commit/daca48f0fb17b7ae0b62a2ac40cf0e491b2fd0b7), [`257d14f`](https://github.com/mastra-ai/mastra/commit/257d14faca5931f2e4186fc165b6f0b1f915deee), [`352f25d`](https://github.com/mastra-ai/mastra/commit/352f25da316b24cdd5b410fd8dddf6a8b763da2a), [`93477d0`](https://github.com/mastra-ai/mastra/commit/93477d0769b8a13ea5ed73d508d967fb23eaeed9), [`31c78b3`](https://github.com/mastra-ai/mastra/commit/31c78b3eb28f58a8017f1dcc795c33214d87feac), [`0bc0720`](https://github.com/mastra-ai/mastra/commit/0bc07201095791858087cc56f353fcd65e87ab54), [`36516ac`](https://github.com/mastra-ai/mastra/commit/36516aca1021cbeb42e74751b46a2614101f37c8), [`e947652`](https://github.com/mastra-ai/mastra/commit/e9476527fdecb4449e54570e80dfaf8466901254), [`3c6ef79`](https://github.com/mastra-ai/mastra/commit/3c6ef798481e00d6d22563be2de98818fd4dd5e0), [`9257d01`](https://github.com/mastra-ai/mastra/commit/9257d01d1366d81f84c582fe02b5e200cf9621f4), [`ec248f6`](https://github.com/mastra-ai/mastra/commit/ec248f6b56e8a037c066c49b2178e2507471d988)]:
23
+ - @mastra/core@1.9.0-alpha.0
24
+
3
25
  ## 1.1.1
4
26
 
5
27
  ### Patch Changes
package/LICENSE.md CHANGED
@@ -1,3 +1,18 @@
1
+ Portions of this software are licensed as follows:
2
+
3
+ - All content that resides under any directory named "ee/" within this
4
+ repository, including but not limited to:
5
+ - `packages/core/src/auth/ee/`
6
+ - `packages/server/src/server/auth/ee/`
7
+ is licensed under the license defined in `ee/LICENSE`.
8
+
9
+ - All third-party components incorporated into the Mastra Software are
10
+ licensed under the original license provided by the owner of the
11
+ applicable component.
12
+
13
+ - Content outside of the above-mentioned directories or restrictions is
14
+ available under the "Apache License 2.0" as defined below.
15
+
1
16
  # Apache License 2.0
2
17
 
3
18
  Copyright (c) 2025 Kepler Software, Inc.
@@ -1 +1 @@
1
- {"version":3,"file":"execution-engine.d.ts","sourceRoot":"","sources":["../src/execution-engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,sBAAsB,EAAmC,MAAM,wBAAwB,CAAC;AACjG,OAAO,KAAK,EACV,gBAAgB,E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EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;CAyRnD"}
package/dist/index.cjs CHANGED
@@ -129,9 +129,10 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
129
129
  * object is finally JSON.stringify'd, our error's toJSON() is called.
130
130
  */
131
131
  async wrapDurableOperation(operationId, operationFn) {
132
- return this.inngestStep.run(operationId, async () => {
132
+ const result = await this.inngestStep.run(operationId, async () => {
133
133
  try {
134
- return await operationFn();
134
+ const fnResult = await operationFn();
135
+ return fnResult;
135
136
  } catch (e) {
136
137
  const errorInstance = error.getErrorFromUnknown(e, {
137
138
  serializeStack: false,
@@ -146,6 +147,7 @@ var InngestExecutionEngine = class extends workflows.DefaultExecutionEngine {
146
147
  });
147
148
  }
148
149
  });
150
+ return result;
149
151
  }
150
152
  /**
151
153
  * Provide Inngest step primitive in engine context
@@ -672,58 +674,158 @@ var InngestRun = class extends workflows.Run {
672
674
  }
673
675
  throw new inngest.NonRetriableError(`Failed to get runs after ${maxRetries} attempts: ${lastError?.message}`);
674
676
  }
677
+ /**
678
+ * Get run output using hybrid approach: realtime subscription + polling fallback.
679
+ * Resolves as soon as either method detects completion.
680
+ */
675
681
  async getRunOutput(eventId, maxWaitMs = 3e5) {
676
- const startTime = Date.now();
677
682
  const storage = this.#mastra?.getStorage();
678
683
  const workflowsStore = await storage?.getStore("workflows");
679
- while (Date.now() - startTime < maxWaitMs) {
680
- let runs;
681
- try {
682
- runs = await this.getRuns(eventId);
683
- } catch (error) {
684
- if (error instanceof inngest.NonRetriableError) {
685
- throw error;
684
+ return new Promise((resolve, reject) => {
685
+ let resolved = false;
686
+ let unsubscribe = null;
687
+ let pollTimeoutId = null;
688
+ const cleanup = () => {
689
+ if (unsubscribe) {
690
+ try {
691
+ unsubscribe();
692
+ } catch {
693
+ }
686
694
  }
687
- throw new inngest.NonRetriableError(
688
- `Failed to poll workflow status: ${error instanceof Error ? error.message : String(error)}`
689
- );
690
- }
691
- if (runs?.[0]?.status === "Completed" && runs?.[0]?.event_id === eventId) {
692
- if (runs?.[0]?.output?.runId !== void 0) {
693
- return runs[0];
695
+ if (pollTimeoutId) {
696
+ clearTimeout(pollTimeoutId);
694
697
  }
695
- await new Promise((resolve) => setTimeout(resolve, 1e3 + Math.random() * 1e3));
696
- continue;
697
- }
698
- if (runs?.[0]?.status === "Failed") {
699
- const snapshot = await workflowsStore?.loadWorkflowSnapshot({
700
- workflowName: this.workflowId,
701
- runId: this.runId
702
- });
703
- if (snapshot?.context) {
704
- snapshot.context = workflows.hydrateSerializedStepErrors(snapshot.context);
698
+ };
699
+ const handleResult = (result, _source) => {
700
+ if (!resolved) {
701
+ resolved = true;
702
+ cleanup();
703
+ resolve(result);
705
704
  }
706
- return {
707
- output: {
708
- result: {
709
- steps: snapshot?.context,
710
- status: "failed",
711
- // Get the original error from NonRetriableError's cause (which contains the workflow result)
712
- error: error.getErrorFromUnknown(runs?.[0]?.output?.cause?.error, { serializeStack: false })
705
+ };
706
+ const handleError = (error, _source) => {
707
+ if (!resolved) {
708
+ resolved = true;
709
+ cleanup();
710
+ reject(error);
711
+ }
712
+ };
713
+ let realtimeStreamPromise = null;
714
+ const startRealtimeSubscription = async () => {
715
+ try {
716
+ realtimeStreamPromise = realtime.subscribe(
717
+ {
718
+ channel: `workflow:${this.workflowId}:${this.runId}`,
719
+ topics: ["watch"],
720
+ app: this.inngest
721
+ },
722
+ async (message) => {
723
+ if (resolved) return;
724
+ const event = message.data;
725
+ if (event?.type === "workflow-finish") {
726
+ const snapshot = await workflowsStore?.loadWorkflowSnapshot({
727
+ workflowName: this.workflowId,
728
+ runId: this.runId
729
+ });
730
+ if (snapshot?.context) {
731
+ snapshot.context = workflows.hydrateSerializedStepErrors(snapshot.context);
732
+ }
733
+ const result = {
734
+ output: {
735
+ result: {
736
+ steps: snapshot?.context,
737
+ status: event.payload.status,
738
+ result: event.payload.result,
739
+ error: event.payload.error ? error.getErrorFromUnknown(event.payload.error, { serializeStack: false }) : void 0
740
+ }
741
+ }
742
+ };
743
+ handleResult(result);
744
+ }
713
745
  }
746
+ );
747
+ unsubscribe = () => {
748
+ realtimeStreamPromise?.then((stream) => stream.cancel().catch(() => {
749
+ })).catch(() => {
750
+ });
751
+ };
752
+ await realtimeStreamPromise;
753
+ } catch {
754
+ }
755
+ };
756
+ const startPolling = async () => {
757
+ const startTime = Date.now();
758
+ const poll = async () => {
759
+ if (resolved) {
760
+ return;
761
+ }
762
+ if (Date.now() - startTime >= maxWaitMs) {
763
+ handleError(new inngest.NonRetriableError(`Workflow did not complete within ${maxWaitMs}ms`));
764
+ return;
765
+ }
766
+ try {
767
+ const runs = await this.getRuns(eventId);
768
+ const run = runs?.find((r) => r.event_id === eventId);
769
+ if (run?.status === "Completed") {
770
+ const snapshot = await workflowsStore?.loadWorkflowSnapshot({
771
+ workflowName: this.workflowId,
772
+ runId: this.runId
773
+ });
774
+ if (snapshot?.context) {
775
+ snapshot.context = workflows.hydrateSerializedStepErrors(snapshot.context);
776
+ }
777
+ handleResult({ output: { result: { steps: snapshot?.context, status: "success" } } });
778
+ return;
779
+ }
780
+ if (run?.status === "Failed") {
781
+ const snapshot = await workflowsStore?.loadWorkflowSnapshot({
782
+ workflowName: this.workflowId,
783
+ runId: this.runId
784
+ });
785
+ if (snapshot?.context) {
786
+ snapshot.context = workflows.hydrateSerializedStepErrors(snapshot.context);
787
+ }
788
+ handleResult(
789
+ {
790
+ output: {
791
+ result: {
792
+ steps: snapshot?.context,
793
+ status: "failed",
794
+ error: error.getErrorFromUnknown(run?.output?.cause?.error, { serializeStack: false })
795
+ }
796
+ }
797
+ });
798
+ return;
799
+ }
800
+ if (run?.status === "Cancelled") {
801
+ const snapshot = await workflowsStore?.loadWorkflowSnapshot({
802
+ workflowName: this.workflowId,
803
+ runId: this.runId
804
+ });
805
+ if (snapshot?.context) {
806
+ snapshot.context = workflows.hydrateSerializedStepErrors(snapshot.context);
807
+ }
808
+ handleResult(
809
+ { output: { result: { steps: snapshot?.context, status: "canceled" } } });
810
+ return;
811
+ }
812
+ pollTimeoutId = setTimeout(poll, 200 + Math.random() * 200);
813
+ } catch (error) {
814
+ if (error instanceof inngest.NonRetriableError) {
815
+ handleError(error);
816
+ return;
817
+ }
818
+ handleError(
819
+ new inngest.NonRetriableError(
820
+ `Failed to poll workflow status: ${error instanceof Error ? error.message : String(error)}`
821
+ ));
714
822
  }
715
823
  };
716
- }
717
- if (runs?.[0]?.status === "Cancelled") {
718
- const snapshot = await workflowsStore?.loadWorkflowSnapshot({
719
- workflowName: this.workflowId,
720
- runId: this.runId
721
- });
722
- return { output: { result: { steps: snapshot?.context, status: "canceled" } } };
723
- }
724
- await new Promise((resolve) => setTimeout(resolve, 1e3 + Math.random() * 1e3));
725
- }
726
- throw new inngest.NonRetriableError(`Workflow did not complete within ${maxWaitMs}ms`);
824
+ void poll();
825
+ };
826
+ void startRealtimeSubscription();
827
+ void startPolling();
828
+ });
727
829
  }
728
830
  async cancel() {
729
831
  const storage = this.#mastra?.getStorage();
@@ -831,8 +933,9 @@ var InngestRun = class extends workflows.Run {
831
933
  });
832
934
  const inputDataToUse = await this._validateInput(inputData);
833
935
  const initialStateToUse = await this._validateInitialState(initialState ?? {});
936
+ const eventName = `workflow.${this.workflowId}`;
834
937
  const eventOutput = await this.inngest.send({
835
- name: `workflow.${this.workflowId}`,
938
+ name: eventName,
836
939
  data: {
837
940
  inputData: inputDataToUse,
838
941
  initialState: initialStateToUse,
@@ -870,19 +973,23 @@ var InngestRun = class extends workflows.Run {
870
973
  }
871
974
  async _resume(params) {
872
975
  const storage = this.#mastra?.getStorage();
873
- let steps = [];
874
- if (typeof params.step === "string") {
875
- steps = params.step.split(".");
876
- } else {
877
- steps = (Array.isArray(params.step) ? params.step : [params.step]).map(
878
- (step) => typeof step === "string" ? step : step?.id
879
- );
880
- }
881
976
  const workflowsStore = await storage?.getStore("workflows");
882
977
  const snapshot = await workflowsStore?.loadWorkflowSnapshot({
883
978
  workflowName: this.workflowId,
884
979
  runId: this.runId
885
980
  });
981
+ const snapshotResumeLabel = params.label ? snapshot?.resumeLabels?.[params.label] : void 0;
982
+ const stepParam = snapshotResumeLabel?.stepId ?? params.step;
983
+ let steps = [];
984
+ if (stepParam) {
985
+ if (typeof stepParam === "string") {
986
+ steps = stepParam.split(".");
987
+ } else {
988
+ steps = (Array.isArray(stepParam) ? stepParam : [stepParam]).map(
989
+ (step) => typeof step === "string" ? step : step?.id
990
+ );
991
+ }
992
+ }
886
993
  const suspendedStep = this.workflowSteps[steps?.[0] ?? ""];
887
994
  const resumeDataToUse = await this._validateResumeData(params.resumeData, suspendedStep);
888
995
  const persistedRequestContext = snapshot?.requestContext ?? {};
@@ -1469,46 +1576,117 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
1469
1576
  } catch (error) {
1470
1577
  throw error;
1471
1578
  }
1472
- await step.run(`workflow.${this.id}.finalize`, async () => {
1473
- if (result.status !== "paused") {
1474
- await engine.invokeLifecycleCallbacksInternal({
1475
- status: result.status,
1476
- result: "result" in result ? result.result : void 0,
1477
- error: "error" in result ? result.error : void 0,
1478
- steps: result.steps,
1479
- tripwire: "tripwire" in result ? result.tripwire : void 0,
1480
- runId,
1481
- workflowId: this.id,
1482
- resourceId,
1483
- input: inputData,
1484
- requestContext,
1485
- state: result.state ?? initialState ?? {}
1579
+ let finalizeError;
1580
+ let finalizeErrored = false;
1581
+ try {
1582
+ await step.run(`workflow.${this.id}.finalize`, async () => {
1583
+ if (result.status !== "paused") {
1584
+ await engine.invokeLifecycleCallbacksInternal({
1585
+ status: result.status,
1586
+ result: "result" in result ? result.result : void 0,
1587
+ error: "error" in result ? result.error : void 0,
1588
+ steps: result.steps,
1589
+ tripwire: "tripwire" in result ? result.tripwire : void 0,
1590
+ runId,
1591
+ workflowId: this.id,
1592
+ resourceId,
1593
+ input: inputData,
1594
+ requestContext,
1595
+ state: result.state ?? initialState ?? {}
1596
+ });
1597
+ }
1598
+ if (workflowSpanData) {
1599
+ const observability = mastra?.observability?.getSelectedInstance({ requestContext });
1600
+ if (observability) {
1601
+ const workflowSpan = observability.rebuildSpan(workflowSpanData);
1602
+ if (result.status === "failed") {
1603
+ workflowSpan.error({
1604
+ error: result.error instanceof Error ? result.error : new Error(String(result.error)),
1605
+ attributes: { status: "failed" }
1606
+ });
1607
+ } else {
1608
+ workflowSpan.end({
1609
+ output: result.status === "success" ? result.result : void 0,
1610
+ attributes: { status: result.status }
1611
+ });
1612
+ }
1613
+ }
1614
+ }
1615
+ const shouldPersistFinalSnapshot = this.options.shouldPersistSnapshot({
1616
+ workflowStatus: result.status,
1617
+ stepResults: result.steps
1486
1618
  });
1487
- }
1488
- if (workflowSpanData) {
1489
- const observability = mastra?.observability?.getSelectedInstance({ requestContext });
1490
- if (observability) {
1491
- const workflowSpan = observability.rebuildSpan(workflowSpanData);
1492
- if (result.status === "failed") {
1493
- workflowSpan.error({
1494
- error: result.error instanceof Error ? result.error : new Error(String(result.error)),
1495
- attributes: { status: "failed" }
1496
- });
1497
- } else {
1498
- workflowSpan.end({
1499
- output: result.status === "success" ? result.result : void 0,
1500
- attributes: { status: result.status }
1619
+ if (shouldPersistFinalSnapshot) {
1620
+ const workflowsStore = await mastra?.getStorage()?.getStore("workflows");
1621
+ if (workflowsStore) {
1622
+ let existingSnapshot;
1623
+ if (result.status === "suspended") {
1624
+ existingSnapshot = await workflowsStore.loadWorkflowSnapshot({
1625
+ workflowName: this.id,
1626
+ runId
1627
+ }) ?? void 0;
1628
+ }
1629
+ await workflowsStore.persistWorkflowSnapshot({
1630
+ workflowName: this.id,
1631
+ runId,
1632
+ resourceId,
1633
+ snapshot: {
1634
+ runId,
1635
+ status: result.status,
1636
+ value: result.state ?? initialState ?? {},
1637
+ context: toSnapshotContext(result.steps),
1638
+ activePaths: [],
1639
+ activeStepsPath: {},
1640
+ serializedStepGraph: this.serializedStepGraph,
1641
+ suspendedPaths: existingSnapshot?.suspendedPaths ?? {},
1642
+ waitingPaths: {},
1643
+ resumeLabels: existingSnapshot?.resumeLabels ?? result.resumeLabels ?? {},
1644
+ result: result.status === "success" ? toSnapshotResult(result.result) : void 0,
1645
+ error: result.status === "failed" ? result.error : void 0,
1646
+ timestamp: Date.now()
1647
+ }
1501
1648
  });
1502
1649
  }
1503
1650
  }
1651
+ try {
1652
+ await pubsub.publish(`workflow.events.v2.${runId}`, {
1653
+ type: "watch",
1654
+ runId,
1655
+ data: {
1656
+ type: "workflow-finish",
1657
+ payload: {
1658
+ status: result.status,
1659
+ result: result.status === "success" ? result.result : void 0,
1660
+ error: result.status === "failed" ? result.error : void 0
1661
+ }
1662
+ }
1663
+ });
1664
+ } catch (publishError) {
1665
+ this.logger.debug?.("Failed to publish workflow-finish event:", publishError);
1666
+ }
1667
+ if (result.status === "failed") {
1668
+ throw new inngest.NonRetriableError(`Workflow failed`, {
1669
+ cause: result
1670
+ });
1671
+ }
1672
+ return result;
1673
+ });
1674
+ } catch (error) {
1675
+ finalizeErrored = true;
1676
+ finalizeError = error;
1677
+ } finally {
1678
+ const observability = mastra?.observability?.getSelectedInstance({ requestContext });
1679
+ if (observability) {
1680
+ try {
1681
+ await observability.flush();
1682
+ } catch (flushError) {
1683
+ this.logger.debug?.("Failed to flush observability:", flushError);
1684
+ }
1504
1685
  }
1505
- if (result.status === "failed") {
1506
- throw new inngest.NonRetriableError(`Workflow failed`, {
1507
- cause: result
1508
- });
1509
- }
1510
- return result;
1511
- });
1686
+ }
1687
+ if (finalizeErrored) {
1688
+ throw finalizeError;
1689
+ }
1512
1690
  return { result, runId };
1513
1691
  }
1514
1692
  );
@@ -1535,6 +1713,12 @@ var InngestWorkflow = class _InngestWorkflow extends workflows.Workflow {
1535
1713
  ];
1536
1714
  }
1537
1715
  };
1716
+ function toSnapshotContext(steps) {
1717
+ return steps;
1718
+ }
1719
+ function toSnapshotResult(output) {
1720
+ return output;
1721
+ }
1538
1722
  function prepareServeOptions({ mastra, inngest, functions: userFunctions = [], registerOptions }) {
1539
1723
  const wfs = mastra.listWorkflows();
1540
1724
  const workflowFunctions = Array.from(
@@ -2216,6 +2400,7 @@ function createStepFromProcessor(processor) {
2216
2400
  }
2217
2401
  function init(inngest) {
2218
2402
  return {
2403
+ createTool: tools.createTool,
2219
2404
  createWorkflow(params) {
2220
2405
  return new InngestWorkflow(
2221
2406
  params,