@mastra/inngest 0.0.0-vnext-inngest-20250506132005 → 0.0.0-vnext-inngest-20250508110322

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,21 +1,12 @@
1
1
  # @mastra/inngest
2
2
 
3
- ## 0.0.0-vnext-inngest-20250506132005
3
+ ## 0.0.0-vnext-inngest-20250508110322
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies [6052aa6]
8
- - Updated dependencies [967b41c]
9
- - Updated dependencies [3d2fb5c]
10
- - Updated dependencies [26738f4]
11
- - Updated dependencies [4155f47]
12
- - Updated dependencies [7eeb2bc]
13
- - Updated dependencies [b804723]
14
- - Updated dependencies [8607972]
15
- - Updated dependencies [ccef9f9]
16
- - Updated dependencies [0097d50]
17
- - Updated dependencies [7eeb2bc]
18
- - Updated dependencies [17826a9]
19
- - Updated dependencies [fba031f]
20
- - Updated dependencies [51e6923]
21
- - @mastra/core@0.0.0-vnext-inngest-20250506132005
7
+ - Updated dependencies [526c570]
8
+ - Updated dependencies [9cd1a46]
9
+ - Updated dependencies [b5d2de0]
10
+ - Updated dependencies [644f8ad]
11
+ - Updated dependencies [70dbf51]
12
+ - @mastra/core@0.0.0-vnext-inngest-20250508110322
@@ -1,4 +1,4 @@
1
- import { BaseContext } from 'inngest';
1
+ import type { BaseContext } from 'inngest';
2
2
  import { ClientOptions } from 'inngest';
3
3
  import { cloneStep } from '@mastra/core/workflows/vNext';
4
4
  import { createStep } from '@mastra/core/workflows/vNext';
@@ -8,17 +8,17 @@ import type { ExecutionContext } from '@mastra/core/workflows/vNext';
8
8
  import type { ExecutionEngine } from '@mastra/core/workflows/vNext';
9
9
  import type { ExecutionGraph } from '@mastra/core/workflows/vNext';
10
10
  import { Handler } from 'inngest';
11
- import { Inngest } from 'inngest';
11
+ import type { Inngest } from 'inngest';
12
12
  import { InngestFunction } from 'inngest';
13
13
  import { InngestMiddleware } from 'inngest';
14
- import { Mastra } from '@mastra/core';
15
- import { NewStep } from '@mastra/core/workflows/vNext';
14
+ import type { Mastra } from '@mastra/core';
15
+ import type { NewStep } from '@mastra/core/workflows/vNext';
16
16
  import { NewWorkflow } from '@mastra/core/workflows/vNext';
17
17
  import type { NewWorkflowConfig } from '@mastra/core/workflows/vNext';
18
18
  import { Run } from '@mastra/core/workflows/vNext';
19
19
  import { RuntimeContext } from '@mastra/core/di';
20
20
  import { serve as serve_2 } from 'inngest/hono';
21
- import { Span } from '@opentelemetry/api';
21
+ import type { Span } from '@opentelemetry/api';
22
22
  import type { StepFlowEntry } from '@mastra/core/workflows/vNext';
23
23
  import type { StepResult } from '@mastra/core/workflows/vNext';
24
24
  import type { WorkflowResult } from '@mastra/core/workflows/vNext';
@@ -126,10 +126,11 @@ export declare class InngestRun<TSteps extends NewStep<string, any, any>[] = New
126
126
  attempts?: number;
127
127
  delay?: number;
128
128
  };
129
+ cleanup?: () => void;
129
130
  }, inngest: Inngest);
130
131
  getRuns(eventId: string): Promise<any>;
131
132
  getRunOutput(eventId: string): Promise<any>;
132
- start({ inputData, runtimeContext, }: {
133
+ start({ inputData, }: {
133
134
  inputData?: z.infer<TInput>;
134
135
  runtimeContext?: RuntimeContext;
135
136
  }): Promise<WorkflowResult<TOutput, TSteps>>;
@@ -1,4 +1,4 @@
1
- import { BaseContext } from 'inngest';
1
+ import type { BaseContext } from 'inngest';
2
2
  import { ClientOptions } from 'inngest';
3
3
  import { cloneStep } from '@mastra/core/workflows/vNext';
4
4
  import { createStep } from '@mastra/core/workflows/vNext';
@@ -8,17 +8,17 @@ import type { ExecutionContext } from '@mastra/core/workflows/vNext';
8
8
  import type { ExecutionEngine } from '@mastra/core/workflows/vNext';
9
9
  import type { ExecutionGraph } from '@mastra/core/workflows/vNext';
10
10
  import { Handler } from 'inngest';
11
- import { Inngest } from 'inngest';
11
+ import type { Inngest } from 'inngest';
12
12
  import { InngestFunction } from 'inngest';
13
13
  import { InngestMiddleware } from 'inngest';
14
- import { Mastra } from '@mastra/core';
15
- import { NewStep } from '@mastra/core/workflows/vNext';
14
+ import type { Mastra } from '@mastra/core';
15
+ import type { NewStep } from '@mastra/core/workflows/vNext';
16
16
  import { NewWorkflow } from '@mastra/core/workflows/vNext';
17
17
  import type { NewWorkflowConfig } from '@mastra/core/workflows/vNext';
18
18
  import { Run } from '@mastra/core/workflows/vNext';
19
19
  import { RuntimeContext } from '@mastra/core/di';
20
20
  import { serve as serve_2 } from 'inngest/hono';
21
- import { Span } from '@opentelemetry/api';
21
+ import type { Span } from '@opentelemetry/api';
22
22
  import type { StepFlowEntry } from '@mastra/core/workflows/vNext';
23
23
  import type { StepResult } from '@mastra/core/workflows/vNext';
24
24
  import type { WorkflowResult } from '@mastra/core/workflows/vNext';
@@ -126,10 +126,11 @@ export declare class InngestRun<TSteps extends NewStep<string, any, any>[] = New
126
126
  attempts?: number;
127
127
  delay?: number;
128
128
  };
129
+ cleanup?: () => void;
129
130
  }, inngest: Inngest);
130
131
  getRuns(eventId: string): Promise<any>;
131
132
  getRunOutput(eventId: string): Promise<any>;
132
- start({ inputData, runtimeContext, }: {
133
+ start({ inputData, }: {
133
134
  inputData?: z.infer<TInput>;
134
135
  runtimeContext?: RuntimeContext;
135
136
  }): Promise<WorkflowResult<TOutput, TSteps>>;
package/dist/index.cjs CHANGED
@@ -1,16 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var vNext = require('@mastra/core/workflows/vNext');
3
+ var crypto = require('crypto');
4
4
  var realtime = require('@inngest/realtime');
5
- var hono = require('inngest/hono');
6
5
  var di = require('@mastra/core/di');
7
- var crypto = require('crypto');
6
+ var vNext = require('@mastra/core/workflows/vNext');
7
+ var hono = require('inngest/hono');
8
8
 
9
9
  // src/index.ts
10
10
  function serve({ mastra, inngest }) {
11
11
  const wfs = mastra.vnext_getWorkflows();
12
12
  const functions = Object.values(wfs).flatMap((wf) => {
13
13
  if (wf instanceof InngestWorkflow) {
14
+ wf.__registerMastra(mastra);
14
15
  return wf.getFunctions();
15
16
  }
16
17
  return [];
@@ -49,8 +50,7 @@ var InngestRun = class extends vNext.Run {
49
50
  return runs?.[0];
50
51
  }
51
52
  async start({
52
- inputData,
53
- runtimeContext
53
+ inputData
54
54
  }) {
55
55
  const eventOutput = await this.inngest.send({
56
56
  name: `workflow.${this.workflowId}`,
@@ -68,6 +68,7 @@ var InngestRun = class extends vNext.Run {
68
68
  if (result.status === "failed") {
69
69
  result.error = new Error(result.error);
70
70
  }
71
+ this.cleanup?.();
71
72
  return result;
72
73
  }
73
74
  async resume(params) {
@@ -118,6 +119,8 @@ var InngestRun = class extends vNext.Run {
118
119
  return () => {
119
120
  streamPromise.then((stream) => {
120
121
  stream.cancel();
122
+ }).catch((err) => {
123
+ console.error(err);
121
124
  });
122
125
  };
123
126
  }
@@ -134,27 +137,37 @@ var InngestWorkflow = class _InngestWorkflow extends vNext.NewWorkflow {
134
137
  __registerMastra(mastra) {
135
138
  this.#mastra = mastra;
136
139
  this.executionEngine.__registerMastra(mastra);
140
+ const updateNested = (step) => {
141
+ if ((step.type === "step" || step.type === "loop" || step.type === "foreach") && step.step instanceof _InngestWorkflow) {
142
+ step.step.__registerMastra(mastra);
143
+ } else if (step.type === "parallel" || step.type === "conditional") {
144
+ for (const subStep of step.steps) {
145
+ updateNested(subStep);
146
+ }
147
+ }
148
+ };
137
149
  if (this.executionGraph.steps.length) {
138
150
  for (const step of this.executionGraph.steps) {
139
- if (step.type === "step" && step.step instanceof _InngestWorkflow) {
140
- step.step.__registerMastra(mastra);
141
- }
151
+ updateNested(step);
142
152
  }
143
153
  }
144
154
  }
145
155
  createRun(options) {
146
156
  const runIdToUse = options?.runId || crypto.randomUUID();
147
- return new InngestRun(
157
+ const run = new InngestRun(
148
158
  {
149
159
  workflowId: this.id,
150
160
  runId: runIdToUse,
151
161
  executionEngine: this.executionEngine,
152
162
  executionGraph: this.executionGraph,
153
163
  mastra: this.#mastra,
154
- retryConfig: this.retryConfig
164
+ retryConfig: this.retryConfig,
165
+ cleanup: () => this.runs.delete(runIdToUse)
155
166
  },
156
167
  this.inngest
157
168
  );
169
+ this.runs.set(runIdToUse, run);
170
+ return run;
158
171
  }
159
172
  getFunction() {
160
173
  if (this.function) {
package/dist/index.js CHANGED
@@ -1,14 +1,15 @@
1
- import { Run, NewWorkflow, cloneStep, createStep, DefaultExecutionEngine } from '@mastra/core/workflows/vNext';
1
+ import { randomUUID } from 'crypto';
2
2
  import { subscribe } from '@inngest/realtime';
3
- import { serve as serve$1 } from 'inngest/hono';
4
3
  import { RuntimeContext } from '@mastra/core/di';
5
- import { randomUUID } from 'crypto';
4
+ import { Run, NewWorkflow, cloneStep, createStep, DefaultExecutionEngine } from '@mastra/core/workflows/vNext';
5
+ import { serve as serve$1 } from 'inngest/hono';
6
6
 
7
7
  // src/index.ts
8
8
  function serve({ mastra, inngest }) {
9
9
  const wfs = mastra.vnext_getWorkflows();
10
10
  const functions = Object.values(wfs).flatMap((wf) => {
11
11
  if (wf instanceof InngestWorkflow) {
12
+ wf.__registerMastra(mastra);
12
13
  return wf.getFunctions();
13
14
  }
14
15
  return [];
@@ -47,8 +48,7 @@ var InngestRun = class extends Run {
47
48
  return runs?.[0];
48
49
  }
49
50
  async start({
50
- inputData,
51
- runtimeContext
51
+ inputData
52
52
  }) {
53
53
  const eventOutput = await this.inngest.send({
54
54
  name: `workflow.${this.workflowId}`,
@@ -66,6 +66,7 @@ var InngestRun = class extends Run {
66
66
  if (result.status === "failed") {
67
67
  result.error = new Error(result.error);
68
68
  }
69
+ this.cleanup?.();
69
70
  return result;
70
71
  }
71
72
  async resume(params) {
@@ -116,6 +117,8 @@ var InngestRun = class extends Run {
116
117
  return () => {
117
118
  streamPromise.then((stream) => {
118
119
  stream.cancel();
120
+ }).catch((err) => {
121
+ console.error(err);
119
122
  });
120
123
  };
121
124
  }
@@ -132,27 +135,37 @@ var InngestWorkflow = class _InngestWorkflow extends NewWorkflow {
132
135
  __registerMastra(mastra) {
133
136
  this.#mastra = mastra;
134
137
  this.executionEngine.__registerMastra(mastra);
138
+ const updateNested = (step) => {
139
+ if ((step.type === "step" || step.type === "loop" || step.type === "foreach") && step.step instanceof _InngestWorkflow) {
140
+ step.step.__registerMastra(mastra);
141
+ } else if (step.type === "parallel" || step.type === "conditional") {
142
+ for (const subStep of step.steps) {
143
+ updateNested(subStep);
144
+ }
145
+ }
146
+ };
135
147
  if (this.executionGraph.steps.length) {
136
148
  for (const step of this.executionGraph.steps) {
137
- if (step.type === "step" && step.step instanceof _InngestWorkflow) {
138
- step.step.__registerMastra(mastra);
139
- }
149
+ updateNested(step);
140
150
  }
141
151
  }
142
152
  }
143
153
  createRun(options) {
144
154
  const runIdToUse = options?.runId || randomUUID();
145
- return new InngestRun(
155
+ const run = new InngestRun(
146
156
  {
147
157
  workflowId: this.id,
148
158
  runId: runIdToUse,
149
159
  executionEngine: this.executionEngine,
150
160
  executionGraph: this.executionGraph,
151
161
  mastra: this.#mastra,
152
- retryConfig: this.retryConfig
162
+ retryConfig: this.retryConfig,
163
+ cleanup: () => this.runs.delete(runIdToUse)
153
164
  },
154
165
  this.inngest
155
166
  );
167
+ this.runs.set(runIdToUse, run);
168
+ return run;
156
169
  }
157
170
  getFunction() {
158
171
  if (this.function) {
@@ -0,0 +1,6 @@
1
+ import { createConfig } from '@internal/lint/eslint';
2
+
3
+ const config = await createConfig();
4
+
5
+ /** @type {import("eslint").Linter.Config[]} */
6
+ export default [...config.map(conf => ({ ...conf, ignores: [...(conf.ignores || []), '**/vitest.perf.config.ts'] }))];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/inngest",
3
- "version": "0.0.0-vnext-inngest-20250506132005",
3
+ "version": "0.0.0-vnext-inngest-20250508110322",
4
4
  "description": "Mastra Inngest integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "inngest": "^3.35.1",
24
24
  "zod": "^3.24.2",
25
25
  "@opentelemetry/api": "^1.9.0",
26
- "@mastra/core": "0.0.0-vnext-inngest-20250506132005"
26
+ "@mastra/core": "0.0.0-vnext-inngest-20250508110322"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@ai-sdk/openai": "^1.2.1",
@@ -38,8 +38,8 @@
38
38
  "tsup": "^8.4.0",
39
39
  "typescript": "^5.8.2",
40
40
  "vitest": "^2.1.9",
41
- "@mastra/deployer": "0.0.0-vnext-inngest-20250506132005",
42
- "@internal/lint": "0.0.0-vnext-inngest-20250506132005"
41
+ "@mastra/deployer": "0.0.0-vnext-inngest-20250508110322",
42
+ "@internal/lint": "0.0.0-vnext-inngest-20250508110322"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
package/src/index.test.ts CHANGED
@@ -1,22 +1,21 @@
1
- import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
- import { Inngest } from 'inngest';
3
- import { realtimeMiddleware } from '@inngest/realtime';
4
-
1
+ import { randomUUID } from 'crypto';
5
2
  import fs from 'fs';
6
3
  import path from 'path';
7
- import { $ } from 'execa';
8
4
  import { openai } from '@ai-sdk/openai';
9
- import { z } from 'zod';
5
+ import { serve } from '@hono/node-server';
6
+ import { realtimeMiddleware } from '@inngest/realtime';
10
7
  import { createTool, Mastra, Telemetry } from '@mastra/core';
11
- import { createHonoServer } from '@mastra/deployer/server';
12
8
  import { Agent } from '@mastra/core/agent';
13
- import { DefaultStorage } from '@mastra/core/storage/libsql';
14
- import { Hono } from 'hono';
15
- import { serve } from '@hono/node-server';
16
- import { init, serve as inngestServe } from './index';
17
9
  import { RuntimeContext } from '@mastra/core/runtime-context';
10
+ import { DefaultStorage } from '@mastra/core/storage/libsql';
11
+ import { createHonoServer } from '@mastra/deployer/server';
12
+ import { $ } from 'execa';
18
13
  import getPort from 'get-port';
19
- import { randomUUID } from 'crypto';
14
+ import { Inngest } from 'inngest';
15
+ import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
16
+
17
+ import { z } from 'zod';
18
+ import { init, serve as inngestServe } from './index';
20
19
 
21
20
  interface LocalTestContext {
22
21
  inngestPort: number;
@@ -24,7 +23,7 @@ interface LocalTestContext {
24
23
  containerName: string;
25
24
  }
26
25
 
27
- describe('MastraInngestWorkflow', ctx => {
26
+ describe('MastraInngestWorkflow', () => {
28
27
  beforeEach<LocalTestContext>(async ctx => {
29
28
  const inngestPort = await getPort();
30
29
  const handlerPort = await getPort();
@@ -2696,7 +2695,7 @@ describe('MastraInngestWorkflow', ctx => {
2696
2695
  baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
2697
2696
  });
2698
2697
 
2699
- const { createWorkflow, createStep } = init(inngest);
2698
+ const { createWorkflow } = init(inngest);
2700
2699
 
2701
2700
  const workflow = createWorkflow({
2702
2701
  id: 'test-workflow',
@@ -3065,7 +3064,7 @@ describe('MastraInngestWorkflow', ctx => {
3065
3064
  .mockImplementationOnce(async ({ suspend }) => {
3066
3065
  await suspend();
3067
3066
  })
3068
- .mockImplementationOnce(({ resumeData }) => {
3067
+ .mockImplementationOnce(() => {
3069
3068
  return { improvedOutput: 'human intervention output' };
3070
3069
  });
3071
3070
  const explainResponseAction = vi.fn().mockResolvedValue({
@@ -4605,7 +4604,7 @@ describe('MastraInngestWorkflow', ctx => {
4605
4604
 
4606
4605
  const { createWorkflow, createStep } = init(inngest);
4607
4606
 
4608
- const start = vi.fn().mockImplementation(async ({ inputData, resume }) => {
4607
+ const start = vi.fn().mockImplementation(async ({ inputData }) => {
4609
4608
  // Get the current value (either from trigger or previous increment)
4610
4609
  const currentValue = inputData.startValue || 0;
4611
4610
 
@@ -5064,16 +5063,6 @@ describe('MastraInngestWorkflow', ctx => {
5064
5063
  const run = counterWorkflow.createRun();
5065
5064
  const result = await run.start({ inputData: { startValue: 0 } });
5066
5065
 
5067
- const runs = await mastra?.getStorage()?.getWorkflowRuns();
5068
- if (runs) {
5069
- for (const run of runs.runs) {
5070
- const snapshot = await mastra?.getStorage()?.loadWorkflowSnapshot({
5071
- workflowName: run.workflowName,
5072
- runId: run.runId,
5073
- });
5074
- }
5075
- }
5076
-
5077
5066
  expect(passthroughStep.execute).toHaveBeenCalledTimes(2);
5078
5067
  expect(result.steps['nested-workflow-c']).toMatchObject({
5079
5068
  status: 'suspended',
package/src/index.ts CHANGED
@@ -1,36 +1,30 @@
1
- import {
2
- NewWorkflow,
3
- type NewStep as Step,
4
- DefaultExecutionEngine,
5
- Run,
6
- cloneStep,
7
- } from '@mastra/core/workflows/vNext';
1
+ import { randomUUID } from 'crypto';
2
+ import { subscribe } from '@inngest/realtime';
3
+ import type { Mastra } from '@mastra/core';
4
+ import { RuntimeContext } from '@mastra/core/di';
5
+ import { NewWorkflow, createStep, Run, DefaultExecutionEngine, cloneStep } from '@mastra/core/workflows/vNext';
8
6
  import type {
9
7
  ExecuteFunction,
10
8
  ExecutionContext,
11
9
  ExecutionEngine,
12
10
  ExecutionGraph,
13
11
  NewStep,
12
+ NewStep as Step,
14
13
  NewWorkflowConfig,
15
14
  StepFlowEntry,
16
15
  StepResult,
17
16
  WorkflowResult,
18
17
  } from '@mastra/core/workflows/vNext';
19
- import { type Span } from '@opentelemetry/api';
20
- import { Inngest, type BaseContext } from 'inngest';
21
- import { subscribe } from '@inngest/realtime';
18
+ import type { Span } from '@opentelemetry/api';
19
+ import type { Inngest, BaseContext } from 'inngest';
22
20
  import { serve as inngestServe } from 'inngest/hono';
23
- import { type Mastra } from '@mastra/core';
24
21
  import type { z } from 'zod';
25
- import { RuntimeContext } from '@mastra/core/di';
26
- import { randomUUID } from 'crypto';
27
-
28
- import { createStep } from '@mastra/core/workflows/vNext';
29
22
 
30
23
  export function serve({ mastra, inngest }: { mastra: Mastra; inngest: Inngest }): ReturnType<typeof inngestServe> {
31
24
  const wfs = mastra.vnext_getWorkflows();
32
25
  const functions = Object.values(wfs).flatMap(wf => {
33
26
  if (wf instanceof InngestWorkflow) {
27
+ wf.__registerMastra(mastra);
34
28
  return wf.getFunctions();
35
29
  }
36
30
  return [];
@@ -60,6 +54,7 @@ export class InngestRun<
60
54
  attempts?: number;
61
55
  delay?: number;
62
56
  };
57
+ cleanup?: () => void;
63
58
  },
64
59
  inngest: Inngest,
65
60
  ) {
@@ -92,7 +87,6 @@ export class InngestRun<
92
87
 
93
88
  async start({
94
89
  inputData,
95
- runtimeContext,
96
90
  }: {
97
91
  inputData?: z.infer<TInput>;
98
92
  runtimeContext?: RuntimeContext;
@@ -114,6 +108,8 @@ export class InngestRun<
114
108
  if (result.status === 'failed') {
115
109
  result.error = new Error(result.error);
116
110
  }
111
+
112
+ this.cleanup?.();
117
113
  return result;
118
114
  }
119
115
 
@@ -175,9 +171,13 @@ export class InngestRun<
175
171
  );
176
172
 
177
173
  return () => {
178
- streamPromise.then((stream: any) => {
179
- stream.cancel();
180
- });
174
+ streamPromise
175
+ .then((stream: any) => {
176
+ stream.cancel();
177
+ })
178
+ .catch(err => {
179
+ console.error(err);
180
+ });
181
181
  };
182
182
  }
183
183
  }
@@ -203,12 +203,22 @@ export class InngestWorkflow<
203
203
  __registerMastra(mastra: Mastra) {
204
204
  this.#mastra = mastra;
205
205
  this.executionEngine.__registerMastra(mastra);
206
+ const updateNested = (step: StepFlowEntry) => {
207
+ if (
208
+ (step.type === 'step' || step.type === 'loop' || step.type === 'foreach') &&
209
+ step.step instanceof InngestWorkflow
210
+ ) {
211
+ step.step.__registerMastra(mastra);
212
+ } else if (step.type === 'parallel' || step.type === 'conditional') {
213
+ for (const subStep of step.steps) {
214
+ updateNested(subStep);
215
+ }
216
+ }
217
+ };
206
218
 
207
219
  if (this.executionGraph.steps.length) {
208
220
  for (const step of this.executionGraph.steps) {
209
- if (step.type === 'step' && step.step instanceof InngestWorkflow) {
210
- step.step.__registerMastra(mastra);
211
- }
221
+ updateNested(step);
212
222
  }
213
223
  }
214
224
  }
@@ -217,7 +227,7 @@ export class InngestWorkflow<
217
227
  const runIdToUse = options?.runId || randomUUID();
218
228
 
219
229
  // Return a new Run instance with object parameters
220
- return new InngestRun(
230
+ const run: Run<TSteps, TInput, TOutput> = new InngestRun(
221
231
  {
222
232
  workflowId: this.id,
223
233
  runId: runIdToUse,
@@ -225,9 +235,13 @@ export class InngestWorkflow<
225
235
  executionGraph: this.executionGraph,
226
236
  mastra: this.#mastra,
227
237
  retryConfig: this.retryConfig,
238
+ cleanup: () => this.runs.delete(runIdToUse),
228
239
  },
229
240
  this.inngest,
230
241
  );
242
+
243
+ this.runs.set(runIdToUse, run);
244
+ return run;
231
245
  }
232
246
 
233
247
  getFunction() {
@@ -842,7 +856,6 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
842
856
  return result ? index : null;
843
857
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
844
858
  } catch (e: unknown) {
845
- e;
846
859
  return null;
847
860
  }
848
861
  }),