@mastra/inngest 0.0.0-vnext-inngest-20250507093737 → 0.0.0-vnext-inngest-20250508111904
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 +7 -16
- package/dist/_tsup-dts-rollup.d.cts +7 -6
- package/dist/_tsup-dts-rollup.d.ts +7 -6
- package/dist/index.cjs +12 -7
- package/dist/index.js +12 -7
- package/eslint.config.js +6 -0
- package/package.json +4 -4
- package/src/index.test.ts +15 -26
- package/src/index.ts +35 -31
package/CHANGELOG.md
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
# @mastra/inngest
|
|
2
2
|
|
|
3
|
-
## 0.0.0-vnext-inngest-
|
|
3
|
+
## 0.0.0-vnext-inngest-20250508111904
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- Updated dependencies [
|
|
8
|
-
- Updated dependencies [
|
|
9
|
-
- Updated dependencies [
|
|
10
|
-
- Updated dependencies [
|
|
11
|
-
- Updated dependencies [
|
|
12
|
-
-
|
|
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-20250507093737
|
|
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-20250508111904
|
|
@@ -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,
|
|
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,
|
|
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,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
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
|
|
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 }) {
|
|
@@ -50,8 +50,7 @@ var InngestRun = class extends vNext.Run {
|
|
|
50
50
|
return runs?.[0];
|
|
51
51
|
}
|
|
52
52
|
async start({
|
|
53
|
-
inputData
|
|
54
|
-
runtimeContext
|
|
53
|
+
inputData
|
|
55
54
|
}) {
|
|
56
55
|
const eventOutput = await this.inngest.send({
|
|
57
56
|
name: `workflow.${this.workflowId}`,
|
|
@@ -69,6 +68,7 @@ var InngestRun = class extends vNext.Run {
|
|
|
69
68
|
if (result.status === "failed") {
|
|
70
69
|
result.error = new Error(result.error);
|
|
71
70
|
}
|
|
71
|
+
this.cleanup?.();
|
|
72
72
|
return result;
|
|
73
73
|
}
|
|
74
74
|
async resume(params) {
|
|
@@ -119,6 +119,8 @@ var InngestRun = class extends vNext.Run {
|
|
|
119
119
|
return () => {
|
|
120
120
|
streamPromise.then((stream) => {
|
|
121
121
|
stream.cancel();
|
|
122
|
+
}).catch((err) => {
|
|
123
|
+
console.error(err);
|
|
122
124
|
});
|
|
123
125
|
};
|
|
124
126
|
}
|
|
@@ -152,17 +154,20 @@ var InngestWorkflow = class _InngestWorkflow extends vNext.NewWorkflow {
|
|
|
152
154
|
}
|
|
153
155
|
createRun(options) {
|
|
154
156
|
const runIdToUse = options?.runId || crypto.randomUUID();
|
|
155
|
-
|
|
157
|
+
const run = this.runs.get(runIdToUse) ?? new InngestRun(
|
|
156
158
|
{
|
|
157
159
|
workflowId: this.id,
|
|
158
160
|
runId: runIdToUse,
|
|
159
161
|
executionEngine: this.executionEngine,
|
|
160
162
|
executionGraph: this.executionGraph,
|
|
161
163
|
mastra: this.#mastra,
|
|
162
|
-
retryConfig: this.retryConfig
|
|
164
|
+
retryConfig: this.retryConfig,
|
|
165
|
+
cleanup: () => this.runs.delete(runIdToUse)
|
|
163
166
|
},
|
|
164
167
|
this.inngest
|
|
165
168
|
);
|
|
169
|
+
this.runs.set(runIdToUse, run);
|
|
170
|
+
return run;
|
|
166
171
|
}
|
|
167
172
|
getFunction() {
|
|
168
173
|
if (this.function) {
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
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 {
|
|
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 }) {
|
|
@@ -48,8 +48,7 @@ var InngestRun = class extends Run {
|
|
|
48
48
|
return runs?.[0];
|
|
49
49
|
}
|
|
50
50
|
async start({
|
|
51
|
-
inputData
|
|
52
|
-
runtimeContext
|
|
51
|
+
inputData
|
|
53
52
|
}) {
|
|
54
53
|
const eventOutput = await this.inngest.send({
|
|
55
54
|
name: `workflow.${this.workflowId}`,
|
|
@@ -67,6 +66,7 @@ var InngestRun = class extends Run {
|
|
|
67
66
|
if (result.status === "failed") {
|
|
68
67
|
result.error = new Error(result.error);
|
|
69
68
|
}
|
|
69
|
+
this.cleanup?.();
|
|
70
70
|
return result;
|
|
71
71
|
}
|
|
72
72
|
async resume(params) {
|
|
@@ -117,6 +117,8 @@ var InngestRun = class extends Run {
|
|
|
117
117
|
return () => {
|
|
118
118
|
streamPromise.then((stream) => {
|
|
119
119
|
stream.cancel();
|
|
120
|
+
}).catch((err) => {
|
|
121
|
+
console.error(err);
|
|
120
122
|
});
|
|
121
123
|
};
|
|
122
124
|
}
|
|
@@ -150,17 +152,20 @@ var InngestWorkflow = class _InngestWorkflow extends NewWorkflow {
|
|
|
150
152
|
}
|
|
151
153
|
createRun(options) {
|
|
152
154
|
const runIdToUse = options?.runId || randomUUID();
|
|
153
|
-
|
|
155
|
+
const run = this.runs.get(runIdToUse) ?? new InngestRun(
|
|
154
156
|
{
|
|
155
157
|
workflowId: this.id,
|
|
156
158
|
runId: runIdToUse,
|
|
157
159
|
executionEngine: this.executionEngine,
|
|
158
160
|
executionGraph: this.executionGraph,
|
|
159
161
|
mastra: this.#mastra,
|
|
160
|
-
retryConfig: this.retryConfig
|
|
162
|
+
retryConfig: this.retryConfig,
|
|
163
|
+
cleanup: () => this.runs.delete(runIdToUse)
|
|
161
164
|
},
|
|
162
165
|
this.inngest
|
|
163
166
|
);
|
|
167
|
+
this.runs.set(runIdToUse, run);
|
|
168
|
+
return run;
|
|
164
169
|
}
|
|
165
170
|
getFunction() {
|
|
166
171
|
if (this.function) {
|
package/eslint.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/inngest",
|
|
3
|
-
"version": "0.0.0-vnext-inngest-
|
|
3
|
+
"version": "0.0.0-vnext-inngest-20250508111904",
|
|
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-
|
|
26
|
+
"@mastra/core": "0.0.0-vnext-inngest-20250508111904"
|
|
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-
|
|
42
|
-
"@internal/lint": "0.0.0-vnext-inngest-
|
|
41
|
+
"@mastra/deployer": "0.0.0-vnext-inngest-20250508111904",
|
|
42
|
+
"@internal/lint": "0.0.0-vnext-inngest-20250508111904"
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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',
|
|
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
|
|
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((
|
|
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
|
|
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,31 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 {
|
|
20
|
-
import { 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();
|
|
@@ -61,6 +54,7 @@ export class InngestRun<
|
|
|
61
54
|
attempts?: number;
|
|
62
55
|
delay?: number;
|
|
63
56
|
};
|
|
57
|
+
cleanup?: () => void;
|
|
64
58
|
},
|
|
65
59
|
inngest: Inngest,
|
|
66
60
|
) {
|
|
@@ -93,7 +87,6 @@ export class InngestRun<
|
|
|
93
87
|
|
|
94
88
|
async start({
|
|
95
89
|
inputData,
|
|
96
|
-
runtimeContext,
|
|
97
90
|
}: {
|
|
98
91
|
inputData?: z.infer<TInput>;
|
|
99
92
|
runtimeContext?: RuntimeContext;
|
|
@@ -115,6 +108,8 @@ export class InngestRun<
|
|
|
115
108
|
if (result.status === 'failed') {
|
|
116
109
|
result.error = new Error(result.error);
|
|
117
110
|
}
|
|
111
|
+
|
|
112
|
+
this.cleanup?.();
|
|
118
113
|
return result;
|
|
119
114
|
}
|
|
120
115
|
|
|
@@ -176,9 +171,13 @@ export class InngestRun<
|
|
|
176
171
|
);
|
|
177
172
|
|
|
178
173
|
return () => {
|
|
179
|
-
streamPromise
|
|
180
|
-
|
|
181
|
-
|
|
174
|
+
streamPromise
|
|
175
|
+
.then((stream: any) => {
|
|
176
|
+
stream.cancel();
|
|
177
|
+
})
|
|
178
|
+
.catch(err => {
|
|
179
|
+
console.error(err);
|
|
180
|
+
});
|
|
182
181
|
};
|
|
183
182
|
}
|
|
184
183
|
}
|
|
@@ -228,17 +227,23 @@ export class InngestWorkflow<
|
|
|
228
227
|
const runIdToUse = options?.runId || randomUUID();
|
|
229
228
|
|
|
230
229
|
// Return a new Run instance with object parameters
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
230
|
+
const run: Run<TSteps, TInput, TOutput> =
|
|
231
|
+
this.runs.get(runIdToUse) ??
|
|
232
|
+
new InngestRun(
|
|
233
|
+
{
|
|
234
|
+
workflowId: this.id,
|
|
235
|
+
runId: runIdToUse,
|
|
236
|
+
executionEngine: this.executionEngine,
|
|
237
|
+
executionGraph: this.executionGraph,
|
|
238
|
+
mastra: this.#mastra,
|
|
239
|
+
retryConfig: this.retryConfig,
|
|
240
|
+
cleanup: () => this.runs.delete(runIdToUse),
|
|
241
|
+
},
|
|
242
|
+
this.inngest,
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
this.runs.set(runIdToUse, run);
|
|
246
|
+
return run;
|
|
242
247
|
}
|
|
243
248
|
|
|
244
249
|
getFunction() {
|
|
@@ -853,7 +858,6 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
|
|
|
853
858
|
return result ? index : null;
|
|
854
859
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
855
860
|
} catch (e: unknown) {
|
|
856
|
-
e;
|
|
857
861
|
return null;
|
|
858
862
|
}
|
|
859
863
|
}),
|