@mastra/inngest 0.0.0-fix-fetching-workflow-snapshots-20250625000954 → 0.0.0-http-transporter-20250702160118

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/src/index.test.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { randomUUID } from 'crypto';
2
1
  import fs from 'fs';
3
2
  import path from 'path';
4
3
  import { openai } from '@ai-sdk/openai';
@@ -12,9 +11,8 @@ import { createHonoServer } from '@mastra/deployer/server';
12
11
  import { DefaultStorage } from '@mastra/libsql';
13
12
  import { MockLanguageModelV1, simulateReadableStream } from 'ai/test';
14
13
  import { $ } from 'execa';
15
- import getPort from 'get-port';
16
14
  import { Inngest } from 'inngest';
17
- import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
15
+ import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest';
18
16
 
19
17
  import { z } from 'zod';
20
18
  import { init, serve as inngestServe } from './index';
@@ -22,27 +20,27 @@ import { init, serve as inngestServe } from './index';
22
20
  interface LocalTestContext {
23
21
  inngestPort: number;
24
22
  handlerPort: number;
25
- containerName: string;
23
+ srv?: any;
24
+ }
25
+
26
+ async function resetInngest() {
27
+ await new Promise(resolve => setTimeout(resolve, 1000));
28
+ await $`docker-compose restart`;
29
+ await new Promise(resolve => setTimeout(resolve, 1500));
26
30
  }
27
31
 
28
32
  describe('MastraInngestWorkflow', () => {
33
+ let globServer: any;
34
+
29
35
  beforeEach<LocalTestContext>(async ctx => {
30
- const inngestPort = await getPort();
31
- const handlerPort = await getPort();
32
- const containerName = randomUUID();
33
- await $`docker run --rm -d --name ${containerName} -p ${inngestPort}:${inngestPort} inngest/inngest:v1.5.10 inngest dev -p ${inngestPort} -u http://host.docker.internal:${handlerPort}/inngest/api`;
36
+ ctx.inngestPort = 4000;
37
+ ctx.handlerPort = 4001;
34
38
 
35
- ctx.inngestPort = inngestPort;
36
- ctx.handlerPort = handlerPort;
37
- ctx.containerName = containerName;
39
+ globServer?.close();
38
40
 
39
41
  vi.restoreAllMocks();
40
42
  });
41
43
 
42
- afterEach<LocalTestContext>(async ctx => {
43
- await $`docker stop ${ctx.containerName}`;
44
- });
45
-
46
44
  describe.sequential('Basic Workflow Execution', () => {
47
45
  it('should be able to bail workflow execution', async ctx => {
48
46
  const inngest = new Inngest({
@@ -105,15 +103,17 @@ describe('MastraInngestWorkflow', () => {
105
103
 
106
104
  const app = await createHonoServer(mastra);
107
105
 
108
- const srv = serve({
106
+ const srv = (globServer = serve({
109
107
  fetch: app.fetch,
110
108
  port: (ctx as any).handlerPort,
111
- });
109
+ }));
110
+
111
+ await resetInngest();
112
112
 
113
113
  const run = await workflow.createRunAsync();
114
+ console.log('running');
114
115
  const result = await run.start({ inputData: { value: 'bail' } });
115
-
116
- await new Promise(resolve => setTimeout(resolve, 2000));
116
+ console.log('result', result);
117
117
 
118
118
  expect(result.steps['step1']).toEqual({
119
119
  status: 'success',
@@ -192,11 +192,11 @@ describe('MastraInngestWorkflow', () => {
192
192
 
193
193
  const app = await createHonoServer(mastra);
194
194
 
195
- const srv = serve({
195
+ const srv = (globServer = serve({
196
196
  fetch: app.fetch,
197
197
  port: (ctx as any).handlerPort,
198
- });
199
- await new Promise(resolve => setTimeout(resolve, 2000));
198
+ }));
199
+ await resetInngest();
200
200
 
201
201
  const run = await workflow.createRunAsync();
202
202
  const result = await run.start({ inputData: {} });
@@ -267,11 +267,11 @@ describe('MastraInngestWorkflow', () => {
267
267
 
268
268
  const app = await createHonoServer(mastra);
269
269
 
270
- const srv = serve({
270
+ const srv = (globServer = serve({
271
271
  fetch: app.fetch,
272
272
  port: (ctx as any).handlerPort,
273
- });
274
- await new Promise(resolve => setTimeout(resolve, 2000));
273
+ }));
274
+ await resetInngest();
275
275
 
276
276
  const run = await workflow.createRunAsync();
277
277
  const result = await run.start({ inputData: {} });
@@ -348,11 +348,11 @@ describe('MastraInngestWorkflow', () => {
348
348
 
349
349
  const app = await createHonoServer(mastra);
350
350
 
351
- const srv = serve({
351
+ const srv = (globServer = serve({
352
352
  fetch: app.fetch,
353
353
  port: (ctx as any).handlerPort,
354
- });
355
- await new Promise(resolve => setTimeout(resolve, 2000));
354
+ }));
355
+ await resetInngest();
356
356
 
357
357
  const run = await workflow.createRunAsync();
358
358
  const result = await run.start({ inputData: {} });
@@ -422,11 +422,11 @@ describe('MastraInngestWorkflow', () => {
422
422
 
423
423
  const app = await createHonoServer(mastra);
424
424
 
425
- const srv = serve({
425
+ const srv = (globServer = serve({
426
426
  fetch: app.fetch,
427
427
  port: (ctx as any).handlerPort,
428
- });
429
- await new Promise(resolve => setTimeout(resolve, 2000));
428
+ }));
429
+ await resetInngest();
430
430
 
431
431
  const run = await workflow.createRunAsync();
432
432
  const startTime = Date.now();
@@ -514,11 +514,11 @@ describe('MastraInngestWorkflow', () => {
514
514
 
515
515
  const app = await createHonoServer(mastra);
516
516
 
517
- const srv = serve({
517
+ const srv = (globServer = serve({
518
518
  fetch: app.fetch,
519
519
  port: (ctx as any).handlerPort,
520
- });
521
- await new Promise(resolve => setTimeout(resolve, 2000));
520
+ }));
521
+ await resetInngest();
522
522
 
523
523
  const run = await workflow.createRunAsync();
524
524
  const startTime = Date.now();
@@ -604,11 +604,11 @@ describe('MastraInngestWorkflow', () => {
604
604
 
605
605
  const app = await createHonoServer(mastra);
606
606
 
607
- const srv = serve({
607
+ const srv = (globServer = serve({
608
608
  fetch: app.fetch,
609
609
  port: (ctx as any).handlerPort,
610
- });
611
- await new Promise(resolve => setTimeout(resolve, 2000));
610
+ }));
611
+ await resetInngest();
612
612
 
613
613
  const run = await workflow.createRunAsync();
614
614
  const startTime = Date.now();
@@ -698,11 +698,11 @@ describe('MastraInngestWorkflow', () => {
698
698
 
699
699
  const app = await createHonoServer(mastra);
700
700
 
701
- const srv = serve({
701
+ const srv = (globServer = serve({
702
702
  fetch: app.fetch,
703
703
  port: (ctx as any).handlerPort,
704
- });
705
- await new Promise(resolve => setTimeout(resolve, 2000));
704
+ }));
705
+ await resetInngest();
706
706
 
707
707
  const run = await workflow.createRunAsync();
708
708
  const startTime = Date.now();
@@ -732,6 +732,203 @@ describe('MastraInngestWorkflow', () => {
732
732
  });
733
733
  });
734
734
 
735
+ describe('abort', () => {
736
+ it('should be able to abort workflow execution in between steps', async ctx => {
737
+ const inngest = new Inngest({
738
+ id: 'mastra',
739
+ baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
740
+ middleware: [realtimeMiddleware()],
741
+ });
742
+
743
+ const { createWorkflow, createStep } = init(inngest);
744
+
745
+ const step1 = createStep({
746
+ id: 'step1',
747
+ execute: async ({ inputData }) => {
748
+ return { result: 'step1: ' + inputData.value };
749
+ },
750
+ inputSchema: z.object({ value: z.string() }),
751
+ outputSchema: z.object({ result: z.string() }),
752
+ });
753
+ const step2 = createStep({
754
+ id: 'step2',
755
+ execute: async ({ inputData }) => {
756
+ return { result: 'step2: ' + inputData.result };
757
+ },
758
+ inputSchema: z.object({ result: z.string() }),
759
+ outputSchema: z.object({ result: z.string() }),
760
+ });
761
+
762
+ const workflow = createWorkflow({
763
+ id: 'test-workflow',
764
+ inputSchema: z.object({}),
765
+ outputSchema: z.object({
766
+ result: z.string(),
767
+ }),
768
+ steps: [step1, step2],
769
+ });
770
+
771
+ workflow.then(step1).sleep(2000).then(step2).commit();
772
+
773
+ const mastra = new Mastra({
774
+ storage: new DefaultStorage({
775
+ url: ':memory:',
776
+ }),
777
+ workflows: {
778
+ 'test-workflow': workflow,
779
+ },
780
+ server: {
781
+ apiRoutes: [
782
+ {
783
+ path: '/inngest/api',
784
+ method: 'ALL',
785
+ createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
786
+ },
787
+ ],
788
+ },
789
+ });
790
+
791
+ const app = await createHonoServer(mastra);
792
+
793
+ const srv = (globServer = serve({
794
+ fetch: app.fetch,
795
+ port: (ctx as any).handlerPort,
796
+ }));
797
+ await resetInngest();
798
+
799
+ const run = await workflow.createRunAsync();
800
+ const p = run.start({ inputData: { value: 'test' } });
801
+
802
+ setTimeout(() => {
803
+ run.cancel();
804
+ }, 1000);
805
+
806
+ const result = await p;
807
+
808
+ srv.close();
809
+
810
+ expect(result.status).toBe('canceled');
811
+ expect(result.steps['step1']).toEqual({
812
+ status: 'success',
813
+ output: { result: 'step1: test' },
814
+ payload: { value: 'test' },
815
+ startedAt: expect.any(Number),
816
+ endedAt: expect.any(Number),
817
+ });
818
+
819
+ expect(result.steps['step2']).toBeUndefined();
820
+ });
821
+
822
+ it('should be able to abort workflow execution during a step', async ctx => {
823
+ const inngest = new Inngest({
824
+ id: 'mastra',
825
+ baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
826
+ middleware: [realtimeMiddleware()],
827
+ });
828
+
829
+ const { createWorkflow, createStep } = init(inngest);
830
+
831
+ const step1 = createStep({
832
+ id: 'step1',
833
+ execute: async ({ inputData }) => {
834
+ return { result: 'step1: ' + inputData.value };
835
+ },
836
+ inputSchema: z.object({ value: z.string() }),
837
+ outputSchema: z.object({ result: z.string() }),
838
+ });
839
+ const step2 = createStep({
840
+ id: 'step2',
841
+ execute: async ({ inputData, abortSignal, abort }) => {
842
+ console.log('abort signal', abortSignal);
843
+ const timeout: Promise<string> = new Promise((resolve, _reject) => {
844
+ const ref = setTimeout(() => {
845
+ resolve('step2: ' + inputData.result);
846
+ }, 5000);
847
+
848
+ abortSignal.addEventListener('abort', () => {
849
+ resolve('');
850
+ clearTimeout(ref);
851
+ });
852
+ });
853
+
854
+ const result = await timeout;
855
+ if (abortSignal.aborted) {
856
+ return abort();
857
+ }
858
+ return { result };
859
+ },
860
+ inputSchema: z.object({ result: z.string() }),
861
+ outputSchema: z.object({ result: z.string() }),
862
+ });
863
+
864
+ const workflow = createWorkflow({
865
+ id: 'test-workflow',
866
+ inputSchema: z.object({}),
867
+ outputSchema: z.object({
868
+ result: z.string(),
869
+ }),
870
+ steps: [step1, step2],
871
+ });
872
+
873
+ workflow.then(step1).then(step2).commit();
874
+
875
+ const mastra = new Mastra({
876
+ storage: new DefaultStorage({
877
+ url: ':memory:',
878
+ }),
879
+ workflows: {
880
+ 'test-workflow': workflow,
881
+ },
882
+ server: {
883
+ apiRoutes: [
884
+ {
885
+ path: '/inngest/api',
886
+ method: 'ALL',
887
+ createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
888
+ },
889
+ ],
890
+ },
891
+ });
892
+
893
+ const app = await createHonoServer(mastra);
894
+
895
+ const srv = (globServer = serve({
896
+ fetch: app.fetch,
897
+ port: (ctx as any).handlerPort,
898
+ }));
899
+ await resetInngest();
900
+
901
+ const run = await workflow.createRunAsync();
902
+ const p = run.start({ inputData: { value: 'test' } });
903
+
904
+ setTimeout(() => {
905
+ run.cancel();
906
+ }, 1000);
907
+
908
+ const result = await p;
909
+ console.log('result', result);
910
+
911
+ srv.close();
912
+
913
+ expect(result.status).toBe('canceled');
914
+ expect(result.steps['step1']).toEqual({
915
+ status: 'success',
916
+ output: { result: 'step1: test' },
917
+ payload: { value: 'test' },
918
+ startedAt: expect.any(Number),
919
+ endedAt: expect.any(Number),
920
+ });
921
+
922
+ // expect(result.steps['step2']).toEqual({
923
+ // status: 'canceled',
924
+ // payload: { result: 'step1: test' },
925
+ // output: undefined,
926
+ // startedAt: expect.any(Number),
927
+ // endedAt: expect.any(Number),
928
+ // });
929
+ });
930
+ });
931
+
735
932
  describe('Variable Resolution', () => {
736
933
  it('should resolve trigger data', async ctx => {
737
934
  const inngest = new Inngest({
@@ -784,10 +981,12 @@ describe('MastraInngestWorkflow', () => {
784
981
 
785
982
  const app = await createHonoServer(mastra);
786
983
 
787
- const srv = serve({
984
+ const srv = (globServer = serve({
788
985
  fetch: app.fetch,
789
986
  port: (ctx as any).handlerPort,
790
- });
987
+ }));
988
+
989
+ await resetInngest();
791
990
 
792
991
  const run = await workflow.createRunAsync();
793
992
  const result = await run.start({ inputData: { inputData: 'test-input' } });
@@ -871,10 +1070,11 @@ describe('MastraInngestWorkflow', () => {
871
1070
 
872
1071
  const app = await createHonoServer(mastra);
873
1072
 
874
- const srv = serve({
1073
+ const srv = (globServer = serve({
875
1074
  fetch: app.fetch,
876
1075
  port: (ctx as any).handlerPort,
877
- });
1076
+ }));
1077
+ await resetInngest();
878
1078
 
879
1079
  const run = await workflow.createRunAsync();
880
1080
  const result = await run.start({ inputData: { inputValue: 'test-input' } });
@@ -938,10 +1138,11 @@ describe('MastraInngestWorkflow', () => {
938
1138
 
939
1139
  const app = await createHonoServer(mastra);
940
1140
 
941
- const srv = serve({
1141
+ const srv = (globServer = serve({
942
1142
  fetch: app.fetch,
943
1143
  port: (ctx as any).handlerPort,
944
- });
1144
+ }));
1145
+ await resetInngest();
945
1146
 
946
1147
  const run = await workflow.createRunAsync();
947
1148
  await run.start({ inputData: { inputData: 'test-input' } });
@@ -1013,10 +1214,11 @@ describe('MastraInngestWorkflow', () => {
1013
1214
 
1014
1215
  const app = await createHonoServer(mastra);
1015
1216
 
1016
- const srv = serve({
1217
+ const srv = (globServer = serve({
1017
1218
  fetch: app.fetch,
1018
1219
  port: (ctx as any).handlerPort,
1019
- });
1220
+ }));
1221
+ await resetInngest();
1020
1222
 
1021
1223
  const run = await workflow.createRunAsync();
1022
1224
  const result = await run.start({ inputData: { cool: 'test-input' } });
@@ -1095,10 +1297,11 @@ describe('MastraInngestWorkflow', () => {
1095
1297
 
1096
1298
  const app = await createHonoServer(mastra);
1097
1299
 
1098
- const srv = serve({
1300
+ const srv = (globServer = serve({
1099
1301
  fetch: app.fetch,
1100
1302
  port: (ctx as any).handlerPort,
1101
- });
1303
+ }));
1304
+ await resetInngest();
1102
1305
 
1103
1306
  const run = await workflow.createRunAsync();
1104
1307
  await run.start({ inputData: {} });
@@ -1198,10 +1401,11 @@ describe('MastraInngestWorkflow', () => {
1198
1401
 
1199
1402
  const app = await createHonoServer(mastra);
1200
1403
 
1201
- const srv = serve({
1404
+ const srv = (globServer = serve({
1202
1405
  fetch: app.fetch,
1203
1406
  port: (ctx as any).handlerPort,
1204
- });
1407
+ }));
1408
+ await resetInngest();
1205
1409
 
1206
1410
  const run = await workflow.createRunAsync();
1207
1411
  const result = await run.start({ inputData: { status: 'success' } });
@@ -1274,10 +1478,11 @@ describe('MastraInngestWorkflow', () => {
1274
1478
 
1275
1479
  const app = await createHonoServer(mastra);
1276
1480
 
1277
- const srv = serve({
1481
+ const srv = (globServer = serve({
1278
1482
  fetch: app.fetch,
1279
1483
  port: (ctx as any).handlerPort,
1280
- });
1484
+ }));
1485
+ await resetInngest();
1281
1486
 
1282
1487
  const run = await workflow.createRunAsync();
1283
1488
  let result: Awaited<ReturnType<typeof run.start>> | undefined = undefined;
@@ -1379,10 +1584,11 @@ describe('MastraInngestWorkflow', () => {
1379
1584
 
1380
1585
  const app = await createHonoServer(mastra);
1381
1586
 
1382
- const srv = serve({
1587
+ const srv = (globServer = serve({
1383
1588
  fetch: app.fetch,
1384
1589
  port: (ctx as any).handlerPort,
1385
- });
1590
+ }));
1591
+ await resetInngest();
1386
1592
 
1387
1593
  const run = await workflow.createRunAsync();
1388
1594
  const result = await run.start({ inputData: { status: 'success' } });
@@ -1462,10 +1668,11 @@ describe('MastraInngestWorkflow', () => {
1462
1668
 
1463
1669
  const app = await createHonoServer(mastra);
1464
1670
 
1465
- const srv = serve({
1671
+ const srv = (globServer = serve({
1466
1672
  fetch: app.fetch,
1467
1673
  port: (ctx as any).handlerPort,
1468
- });
1674
+ }));
1675
+ await resetInngest();
1469
1676
 
1470
1677
  const run = await workflow.createRunAsync();
1471
1678
  const result = await run.start({ inputData: { count: 5 } });
@@ -1529,11 +1736,11 @@ describe('MastraInngestWorkflow', () => {
1529
1736
 
1530
1737
  const app = await createHonoServer(mastra);
1531
1738
 
1532
- const srv = serve({
1739
+ const srv = (globServer = serve({
1533
1740
  fetch: app.fetch,
1534
1741
  port: (ctx as any).handlerPort,
1535
- });
1536
- await new Promise(resolve => setTimeout(resolve, 2000));
1742
+ }));
1743
+ await resetInngest();
1537
1744
 
1538
1745
  const run = await workflow.createRunAsync();
1539
1746
 
@@ -1613,11 +1820,11 @@ describe('MastraInngestWorkflow', () => {
1613
1820
 
1614
1821
  const app = await createHonoServer(mastra);
1615
1822
 
1616
- const srv = serve({
1823
+ const srv = (globServer = serve({
1617
1824
  fetch: app.fetch,
1618
1825
  port: (ctx as any).handlerPort,
1619
- });
1620
- await new Promise(resolve => setTimeout(resolve, 2000));
1826
+ }));
1827
+ await resetInngest();
1621
1828
 
1622
1829
  const run = await workflow.createRunAsync();
1623
1830
  const result = await run.start({ inputData: {} });
@@ -1707,11 +1914,11 @@ describe('MastraInngestWorkflow', () => {
1707
1914
 
1708
1915
  const app = await createHonoServer(mastra);
1709
1916
 
1710
- const srv = serve({
1917
+ const srv = (globServer = serve({
1711
1918
  fetch: app.fetch,
1712
1919
  port: (ctx as any).handlerPort,
1713
- });
1714
- await new Promise(resolve => setTimeout(resolve, 2000));
1920
+ }));
1921
+ await resetInngest();
1715
1922
 
1716
1923
  const run = await mainWorkflow.createRunAsync();
1717
1924
  const result = await run.start({ inputData: {} });
@@ -1835,11 +2042,11 @@ describe('MastraInngestWorkflow', () => {
1835
2042
 
1836
2043
  const app = await createHonoServer(mastra);
1837
2044
 
1838
- const srv = serve({
2045
+ const srv = (globServer = serve({
1839
2046
  fetch: app.fetch,
1840
2047
  port: (ctx as any).handlerPort,
1841
- });
1842
- await new Promise(resolve => setTimeout(resolve, 2000));
2048
+ }));
2049
+ await resetInngest();
1843
2050
 
1844
2051
  const run = await workflow.createRunAsync();
1845
2052
  const result = await run.start({ inputData: {} });
@@ -1937,11 +2144,11 @@ describe('MastraInngestWorkflow', () => {
1937
2144
 
1938
2145
  const app = await createHonoServer(mastra);
1939
2146
 
1940
- const srv = serve({
2147
+ const srv = (globServer = serve({
1941
2148
  fetch: app.fetch,
1942
2149
  port: (ctx as any).handlerPort,
1943
- });
1944
- await new Promise(resolve => setTimeout(resolve, 2000));
2150
+ }));
2151
+ await resetInngest();
1945
2152
 
1946
2153
  const run = await counterWorkflow.createRunAsync();
1947
2154
  const result = await run.start({ inputData: { target: 10, value: 0 } });
@@ -2040,11 +2247,11 @@ describe('MastraInngestWorkflow', () => {
2040
2247
 
2041
2248
  const app = await createHonoServer(mastra);
2042
2249
 
2043
- const srv = serve({
2250
+ const srv = (globServer = serve({
2044
2251
  fetch: app.fetch,
2045
2252
  port: (ctx as any).handlerPort,
2046
- });
2047
- await new Promise(resolve => setTimeout(resolve, 2000));
2253
+ }));
2254
+ await resetInngest();
2048
2255
 
2049
2256
  const run = await counterWorkflow.createRunAsync();
2050
2257
  const result = await run.start({ inputData: { target: 10, value: 0 } });
@@ -2129,11 +2336,11 @@ describe('MastraInngestWorkflow', () => {
2129
2336
 
2130
2337
  const app = await createHonoServer(mastra);
2131
2338
 
2132
- const srv = serve({
2339
+ const srv = (globServer = serve({
2133
2340
  fetch: app.fetch,
2134
2341
  port: (ctx as any).handlerPort,
2135
- });
2136
- await new Promise(resolve => setTimeout(resolve, 2000));
2342
+ }));
2343
+ await resetInngest();
2137
2344
 
2138
2345
  const run = await counterWorkflow.createRunAsync();
2139
2346
  const result = await run.start({ inputData: [{ value: 1 }, { value: 22 }, { value: 333 }] });
@@ -2282,11 +2489,11 @@ describe('MastraInngestWorkflow', () => {
2282
2489
 
2283
2490
  const app = await createHonoServer(mastra);
2284
2491
 
2285
- const srv = serve({
2492
+ const srv = (globServer = serve({
2286
2493
  fetch: app.fetch,
2287
2494
  port: (ctx as any).handlerPort,
2288
- });
2289
- await new Promise(resolve => setTimeout(resolve, 2000));
2495
+ }));
2496
+ await resetInngest();
2290
2497
 
2291
2498
  const run = await counterWorkflow.createRunAsync();
2292
2499
  const result = await run.start({ inputData: { startValue: 1 } });
@@ -2431,15 +2638,17 @@ describe('MastraInngestWorkflow', () => {
2431
2638
 
2432
2639
  const app = await createHonoServer(mastra);
2433
2640
 
2434
- const srv = serve({
2641
+ const srv = (globServer = serve({
2435
2642
  fetch: app.fetch,
2436
2643
  port: (ctx as any).handlerPort,
2437
- });
2438
- await new Promise(resolve => setTimeout(resolve, 2000));
2644
+ }));
2645
+ await resetInngest();
2439
2646
 
2440
2647
  const run = await counterWorkflow.createRunAsync();
2441
2648
  const result = await run.start({ inputData: { startValue: 6 } });
2442
2649
 
2650
+ srv.close();
2651
+
2443
2652
  expect(start).toHaveBeenCalledTimes(1);
2444
2653
  expect(other).toHaveBeenCalledTimes(1);
2445
2654
  expect(final).toHaveBeenCalledTimes(1);
@@ -2447,8 +2656,6 @@ describe('MastraInngestWorkflow', () => {
2447
2656
  expect(result.steps['else-branch'].output).toMatchObject({ finalValue: 26 + 6 + 1 });
2448
2657
  // @ts-ignore
2449
2658
  expect(result.steps.start.output).toMatchObject({ newValue: 7 });
2450
-
2451
- srv.close();
2452
2659
  });
2453
2660
  });
2454
2661
 
@@ -2603,19 +2810,19 @@ describe('MastraInngestWorkflow', () => {
2603
2810
 
2604
2811
  const app = await createHonoServer(mastra);
2605
2812
 
2606
- const srv = serve({
2813
+ const srv = (globServer = serve({
2607
2814
  fetch: app.fetch,
2608
2815
  port: (ctx as any).handlerPort,
2609
- });
2610
- await new Promise(resolve => setTimeout(resolve, 2000));
2816
+ }));
2817
+ await resetInngest();
2611
2818
 
2612
2819
  const run = await workflow.createRunAsync();
2613
2820
  const result = await run.start({ inputData: {} });
2614
2821
 
2822
+ srv.close();
2823
+
2615
2824
  expect(result.steps['nested-a']).toMatchObject({ status: 'success', output: { result: 'success3' } });
2616
2825
  expect(result.steps['nested-b']).toMatchObject({ status: 'success', output: { result: 'success5' } });
2617
-
2618
- srv.close();
2619
2826
  });
2620
2827
  });
2621
2828
 
@@ -2669,21 +2876,21 @@ describe('MastraInngestWorkflow', () => {
2669
2876
 
2670
2877
  const app = await createHonoServer(mastra);
2671
2878
 
2672
- const srv = serve({
2879
+ const srv = (globServer = serve({
2673
2880
  fetch: app.fetch,
2674
2881
  port: (ctx as any).handlerPort,
2675
- });
2676
- await new Promise(resolve => setTimeout(resolve, 2000));
2882
+ }));
2883
+ await resetInngest();
2677
2884
 
2678
2885
  const run = await workflow.createRunAsync();
2679
2886
  const result = await run.start({ inputData: {} });
2680
2887
 
2888
+ srv.close();
2889
+
2681
2890
  expect(result.steps.step1).toMatchObject({ status: 'success', output: { result: 'success' } });
2682
2891
  expect(result.steps.step2).toMatchObject({ status: 'failed', error: 'Step failed' });
2683
2892
  expect(step1.execute).toHaveBeenCalledTimes(1);
2684
2893
  expect(step2.execute).toHaveBeenCalledTimes(1); // 0 retries + 1 initial call
2685
-
2686
- srv.close();
2687
2894
  });
2688
2895
 
2689
2896
  // Need to fix so we can throw for inngest to recognize retries
@@ -2801,11 +3008,11 @@ describe('MastraInngestWorkflow', () => {
2801
3008
 
2802
3009
  const app = await createHonoServer(mastra);
2803
3010
 
2804
- const srv = serve({
3011
+ const srv = (globServer = serve({
2805
3012
  fetch: app.fetch,
2806
3013
  port: (ctx as any).handlerPort,
2807
- });
2808
- await new Promise(resolve => setTimeout(resolve, 2000));
3014
+ }));
3015
+ await resetInngest();
2809
3016
 
2810
3017
  const run = await workflow.createRunAsync();
2811
3018
  const result = await run.start({ inputData: {} });
@@ -2873,11 +3080,11 @@ describe('MastraInngestWorkflow', () => {
2873
3080
 
2874
3081
  const app = await createHonoServer(mastra);
2875
3082
 
2876
- const srv = serve({
3083
+ const srv = (globServer = serve({
2877
3084
  fetch: app.fetch,
2878
3085
  port: (ctx as any).handlerPort,
2879
- });
2880
- await new Promise(resolve => setTimeout(resolve, 2000));
3086
+ }));
3087
+ await resetInngest();
2881
3088
 
2882
3089
  const run = await workflow.createRunAsync();
2883
3090
 
@@ -2890,7 +3097,9 @@ describe('MastraInngestWorkflow', () => {
2890
3097
  });
2891
3098
 
2892
3099
  const executionResult = await run.start({ inputData: {} });
2893
- await new Promise(resolve => setTimeout(resolve, 2000));
3100
+ await new Promise(resolve => setTimeout(resolve, 1000));
3101
+
3102
+ srv.close();
2894
3103
 
2895
3104
  expect(cnt).toBe(5);
2896
3105
  expect(resps.length).toBe(5);
@@ -3002,8 +3211,6 @@ describe('MastraInngestWorkflow', () => {
3002
3211
  status: 'success',
3003
3212
  output: { result: 'success2' },
3004
3213
  });
3005
-
3006
- srv.close();
3007
3214
  });
3008
3215
 
3009
3216
  it('should unsubscribe from transitions when unwatch is called', async ctx => {
@@ -3059,11 +3266,11 @@ describe('MastraInngestWorkflow', () => {
3059
3266
 
3060
3267
  const app = await createHonoServer(mastra);
3061
3268
 
3062
- const srv = serve({
3269
+ const srv = (globServer = serve({
3063
3270
  fetch: app.fetch,
3064
3271
  port: (ctx as any).handlerPort,
3065
- });
3066
- await new Promise(resolve => setTimeout(resolve, 2000));
3272
+ }));
3273
+ await resetInngest();
3067
3274
 
3068
3275
  const onTransition = vi.fn();
3069
3276
  const onTransition2 = vi.fn();
@@ -3231,11 +3438,11 @@ describe('MastraInngestWorkflow', () => {
3231
3438
 
3232
3439
  const app = await createHonoServer(mastra);
3233
3440
 
3234
- const srv = serve({
3441
+ const srv = (globServer = serve({
3235
3442
  fetch: app.fetch,
3236
3443
  port: (ctx as any).handlerPort,
3237
- });
3238
- await new Promise(resolve => setTimeout(resolve, 2000));
3444
+ }));
3445
+ await resetInngest();
3239
3446
 
3240
3447
  const run = await promptEvalWorkflow.createRunAsync();
3241
3448
 
@@ -3381,11 +3588,11 @@ describe('MastraInngestWorkflow', () => {
3381
3588
 
3382
3589
  const app = await createHonoServer(mastra);
3383
3590
 
3384
- const srv = serve({
3591
+ const srv = (globServer = serve({
3385
3592
  fetch: app.fetch,
3386
3593
  port: (ctx as any).handlerPort,
3387
- });
3388
- await new Promise(resolve => setTimeout(resolve, 2000));
3594
+ }));
3595
+ await resetInngest();
3389
3596
 
3390
3597
  const run = await workflow.createRunAsync();
3391
3598
 
@@ -3419,13 +3626,13 @@ describe('MastraInngestWorkflow', () => {
3419
3626
 
3420
3627
  const initialResult = await started;
3421
3628
 
3629
+ srv.close();
3630
+
3422
3631
  expect(initialResult.steps.humanIntervention.status).toBe('suspended');
3423
3632
  expect(initialResult.steps.explainResponse).toBeUndefined();
3424
3633
  expect(humanInterventionAction).toHaveBeenCalledTimes(2);
3425
3634
  expect(explainResponseAction).not.toHaveBeenCalled();
3426
3635
 
3427
- srv.close();
3428
-
3429
3636
  if (!result) {
3430
3637
  throw new Error('Resume failed to return a result');
3431
3638
  }
@@ -3583,11 +3790,11 @@ describe('MastraInngestWorkflow', () => {
3583
3790
 
3584
3791
  const app = await createHonoServer(mastra);
3585
3792
 
3586
- const srv = serve({
3793
+ const srv = (globServer = serve({
3587
3794
  fetch: app.fetch,
3588
3795
  port: (ctx as any).handlerPort,
3589
- });
3590
- await new Promise(resolve => setTimeout(resolve, 2000));
3796
+ }));
3797
+ await resetInngest();
3591
3798
 
3592
3799
  const run = await workflow.createRunAsync();
3593
3800
  const started = run.start({ inputData: { input: 'test' } });
@@ -3640,11 +3847,12 @@ describe('MastraInngestWorkflow', () => {
3640
3847
  // @ts-ignore
3641
3848
  const improvedResponseResult = await improvedResponseResultPromise;
3642
3849
 
3850
+ srv.close();
3851
+
3643
3852
  expect(improvedResponseResult?.steps.humanIntervention.status).toBe('suspended');
3644
3853
  expect(improvedResponseResult?.steps.improveResponse.status).toBe('success');
3645
3854
  expect(improvedResponseResult?.steps.evaluateImprovedResponse.status).toBe('success');
3646
3855
 
3647
- srv.close();
3648
3856
  if (!result) {
3649
3857
  throw new Error('Resume failed to return a result');
3650
3858
  }
@@ -3777,11 +3985,11 @@ describe('MastraInngestWorkflow', () => {
3777
3985
 
3778
3986
  const app = await createHonoServer(mastra);
3779
3987
 
3780
- const srv = serve({
3988
+ const srv = (globServer = serve({
3781
3989
  fetch: app.fetch,
3782
3990
  port: (ctx as any).handlerPort,
3783
- });
3784
- await new Promise(resolve => setTimeout(resolve, 2000));
3991
+ }));
3992
+ await resetInngest();
3785
3993
 
3786
3994
  const run = await promptEvalWorkflow.createRunAsync();
3787
3995
 
@@ -3836,6 +4044,9 @@ describe('MastraInngestWorkflow', () => {
3836
4044
  completenessScore: { score: 0.7 },
3837
4045
  },
3838
4046
  });
4047
+
4048
+ srv.close();
4049
+
3839
4050
  if (!secondResumeResult) {
3840
4051
  throw new Error('Resume failed to return a result');
3841
4052
  }
@@ -3858,8 +4069,6 @@ describe('MastraInngestWorkflow', () => {
3858
4069
  });
3859
4070
 
3860
4071
  expect(promptAgentAction).toHaveBeenCalledTimes(2);
3861
-
3862
- srv.close();
3863
4072
  });
3864
4073
  });
3865
4074
 
@@ -3905,11 +4114,11 @@ describe('MastraInngestWorkflow', () => {
3905
4114
 
3906
4115
  const app = await createHonoServer(mastra);
3907
4116
 
3908
- const srv = serve({
4117
+ const srv = (globServer = serve({
3909
4118
  fetch: app.fetch,
3910
4119
  port: (ctx as any).handlerPort,
3911
- });
3912
- await new Promise(resolve => setTimeout(resolve, 2000));
4120
+ }));
4121
+ await resetInngest();
3913
4122
 
3914
4123
  // Access new instance properties directly - should work without warning
3915
4124
  const run = await workflow.createRunAsync();
@@ -4009,11 +4218,11 @@ describe('MastraInngestWorkflow', () => {
4009
4218
 
4010
4219
  const app = await createHonoServer(mastra);
4011
4220
 
4012
- const srv = serve({
4221
+ const srv = (globServer = serve({
4013
4222
  fetch: app.fetch,
4014
4223
  port: (ctx as any).handlerPort,
4015
- });
4016
- await new Promise(resolve => setTimeout(resolve, 2000));
4224
+ }));
4225
+ await resetInngest();
4017
4226
 
4018
4227
  const run = await workflow.createRunAsync();
4019
4228
  const result = await run.start({
@@ -4146,11 +4355,11 @@ describe('MastraInngestWorkflow', () => {
4146
4355
 
4147
4356
  const app = await createHonoServer(mastra);
4148
4357
 
4149
- const srv = serve({
4358
+ const srv = (globServer = serve({
4150
4359
  fetch: app.fetch,
4151
4360
  port: (ctx as any).handlerPort,
4152
- });
4153
- await new Promise(resolve => setTimeout(resolve, 2000));
4361
+ }));
4362
+ await resetInngest();
4154
4363
 
4155
4364
  const run = await workflow.createRunAsync();
4156
4365
  const result = await run.start({
@@ -4289,11 +4498,11 @@ describe('MastraInngestWorkflow', () => {
4289
4498
 
4290
4499
  const app = await createHonoServer(mastra);
4291
4500
 
4292
- const srv = serve({
4501
+ const srv = (globServer = serve({
4293
4502
  fetch: app.fetch,
4294
4503
  port: (ctx as any).handlerPort,
4295
- });
4296
- await new Promise(resolve => setTimeout(resolve, 2000));
4504
+ }));
4505
+ await resetInngest();
4297
4506
 
4298
4507
  const run = await counterWorkflow.createRunAsync();
4299
4508
  const result = await run.start({ inputData: { startValue: 0 } });
@@ -4441,11 +4650,11 @@ describe('MastraInngestWorkflow', () => {
4441
4650
 
4442
4651
  const app = await createHonoServer(mastra);
4443
4652
 
4444
- const srv = serve({
4653
+ const srv = (globServer = serve({
4445
4654
  fetch: app.fetch,
4446
4655
  port: (ctx as any).handlerPort,
4447
- });
4448
- await new Promise(resolve => setTimeout(resolve, 2000));
4656
+ }));
4657
+ await resetInngest();
4449
4658
 
4450
4659
  const run = await counterWorkflow.createRunAsync();
4451
4660
  const result = await run.start({ inputData: { startValue: 0 } });
@@ -4601,10 +4810,11 @@ describe('MastraInngestWorkflow', () => {
4601
4810
  await next();
4602
4811
  });
4603
4812
 
4604
- const srv = serve({
4813
+ const srv = (globServer = serve({
4605
4814
  fetch: app.fetch,
4606
4815
  port: (ctx as any).handlerPort,
4607
- });
4816
+ }));
4817
+ await resetInngest();
4608
4818
 
4609
4819
  const run = await counterWorkflow.createRunAsync();
4610
4820
  const result = await run.start({ inputData: { startValue: 0 } });
@@ -4760,10 +4970,11 @@ describe('MastraInngestWorkflow', () => {
4760
4970
  await next();
4761
4971
  });
4762
4972
 
4763
- const srv = serve({
4973
+ const srv = (globServer = serve({
4764
4974
  fetch: app.fetch,
4765
4975
  port: (ctx as any).handlerPort,
4766
- });
4976
+ }));
4977
+ await resetInngest();
4767
4978
 
4768
4979
  const run = await counterWorkflow.createRunAsync();
4769
4980
  const result = await run.start({ inputData: { startValue: 0 } });
@@ -4957,10 +5168,11 @@ describe('MastraInngestWorkflow', () => {
4957
5168
  await next();
4958
5169
  });
4959
5170
 
4960
- const srv = serve({
5171
+ const srv = (globServer = serve({
4961
5172
  fetch: app.fetch,
4962
5173
  port: (ctx as any).handlerPort,
4963
- });
5174
+ }));
5175
+ await resetInngest();
4964
5176
 
4965
5177
  const run = await counterWorkflow.createRunAsync();
4966
5178
  const result = await run.start({ inputData: { startValue: 1 } });
@@ -5110,11 +5322,11 @@ describe('MastraInngestWorkflow', () => {
5110
5322
 
5111
5323
  const app = await createHonoServer(mastra);
5112
5324
 
5113
- const srv = serve({
5325
+ const srv = (globServer = serve({
5114
5326
  fetch: app.fetch,
5115
5327
  port: (ctx as any).handlerPort,
5116
- });
5117
- await new Promise(resolve => setTimeout(resolve, 2000));
5328
+ }));
5329
+ await resetInngest();
5118
5330
 
5119
5331
  const run = await counterWorkflow.createRunAsync();
5120
5332
  const result = await run.start({ inputData: { startValue: 0 } });
@@ -5261,10 +5473,11 @@ describe('MastraInngestWorkflow', () => {
5261
5473
  await next();
5262
5474
  });
5263
5475
 
5264
- const srv = serve({
5476
+ const srv = (globServer = serve({
5265
5477
  fetch: app.fetch,
5266
5478
  port: (ctx as any).handlerPort,
5267
- });
5479
+ }));
5480
+ await resetInngest();
5268
5481
 
5269
5482
  const run = await counterWorkflow.createRunAsync();
5270
5483
  const result = await run.start({ inputData: { startValue: 0 } });
@@ -5442,11 +5655,11 @@ describe('MastraInngestWorkflow', () => {
5442
5655
 
5443
5656
  const app = await createHonoServer(mastra);
5444
5657
 
5445
- const srv = serve({
5658
+ const srv = (globServer = serve({
5446
5659
  fetch: app.fetch,
5447
5660
  port: (ctx as any).handlerPort,
5448
- });
5449
- await new Promise(resolve => setTimeout(resolve, 2000));
5661
+ }));
5662
+ await resetInngest();
5450
5663
 
5451
5664
  const run = await counterWorkflow.createRunAsync();
5452
5665
  const result = await run.start({ inputData: { startValue: 0 } });
@@ -5604,11 +5817,11 @@ describe('MastraInngestWorkflow', () => {
5604
5817
 
5605
5818
  const app = await createHonoServer(mastra);
5606
5819
 
5607
- const srv = serve({
5820
+ const srv = (globServer = serve({
5608
5821
  fetch: app.fetch,
5609
5822
  port: (ctx as any).handlerPort,
5610
- });
5611
- await new Promise(resolve => setTimeout(resolve, 2000));
5823
+ }));
5824
+ await resetInngest();
5612
5825
 
5613
5826
  const run = await counterWorkflow.createRunAsync();
5614
5827
  const result = await run.start({ inputData: { startValue: 0 } });
@@ -5679,11 +5892,11 @@ describe('MastraInngestWorkflow', () => {
5679
5892
 
5680
5893
  const app = await createHonoServer(mastra);
5681
5894
 
5682
- const srv = serve({
5895
+ const srv = (globServer = serve({
5683
5896
  fetch: app.fetch,
5684
5897
  port: (ctx as any).handlerPort,
5685
- });
5686
- await new Promise(resolve => setTimeout(resolve, 2000));
5898
+ }));
5899
+ await resetInngest();
5687
5900
 
5688
5901
  // Access new instance properties directly - should work without warning
5689
5902
  const run = await workflow.createRunAsync();
@@ -5742,10 +5955,11 @@ describe('MastraInngestWorkflow', () => {
5742
5955
 
5743
5956
  const app = await createHonoServer(mastra);
5744
5957
 
5745
- const srv = serve({
5958
+ const srv = (globServer = serve({
5746
5959
  fetch: app.fetch,
5747
5960
  port: (ctx as any).handlerPort,
5748
- });
5961
+ }));
5962
+ await resetInngest();
5749
5963
 
5750
5964
  const run = await workflow.createRunAsync();
5751
5965
  const result = await run.start({ runtimeContext });
@@ -5756,7 +5970,7 @@ describe('MastraInngestWorkflow', () => {
5756
5970
  expect(result.steps.step1.output.injectedValue).toBe(testValue);
5757
5971
  });
5758
5972
 
5759
- it('should inject runtimeContext dependencies into steps during resume', async ctx => {
5973
+ it.skip('should inject runtimeContext dependencies into steps during resume', async ctx => {
5760
5974
  const inngest = new Inngest({
5761
5975
  id: 'mastra',
5762
5976
  baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
@@ -5867,10 +6081,11 @@ describe('MastraInngestWorkflow', () => {
5867
6081
 
5868
6082
  const app = await createHonoServer(mastra);
5869
6083
 
5870
- const srv = serve({
6084
+ const srv = (globServer = serve({
5871
6085
  fetch: app.fetch,
5872
6086
  port: (ctx as any).handlerPort,
5873
- });
6087
+ }));
6088
+ await resetInngest();
5874
6089
 
5875
6090
  const run = await workflow.createRunAsync();
5876
6091
  const result = await run.start({});
@@ -5936,10 +6151,11 @@ describe('MastraInngestWorkflow', () => {
5936
6151
 
5937
6152
  const app = await createHonoServer(mastra);
5938
6153
 
5939
- const srv = serve({
6154
+ const srv = (globServer = serve({
5940
6155
  fetch: app.fetch,
5941
6156
  port: (ctx as any).handlerPort,
5942
- });
6157
+ }));
6158
+ await resetInngest();
5943
6159
 
5944
6160
  const runId = 'test-run-id';
5945
6161
  let watchData: StreamEvent[] = [];
@@ -5947,7 +6163,7 @@ describe('MastraInngestWorkflow', () => {
5947
6163
  runId,
5948
6164
  });
5949
6165
 
5950
- await new Promise(resolve => setTimeout(resolve, 1000));
6166
+ await resetInngest();
5951
6167
 
5952
6168
  const { stream, getWorkflowState } = run.stream({ inputData: {} });
5953
6169
 
@@ -5960,73 +6176,81 @@ describe('MastraInngestWorkflow', () => {
5960
6176
 
5961
6177
  const executionResult = await getWorkflowState();
5962
6178
 
5963
- await new Promise(resolve => setTimeout(resolve, 1000));
6179
+ await resetInngest();
5964
6180
 
5965
6181
  srv.close();
5966
6182
 
5967
6183
  expect(watchData.length).toBe(8);
5968
- expect(watchData).toMatchInlineSnapshot(`
5969
- [
5970
- {
5971
- "payload": {
5972
- "runId": "test-run-id",
5973
- },
5974
- "type": "start",
6184
+ expect(watchData).toMatchObject([
6185
+ {
6186
+ payload: {
6187
+ runId: 'test-run-id',
5975
6188
  },
5976
- {
5977
- "payload": {
5978
- "id": "step1",
5979
- },
5980
- "type": "step-start",
6189
+ type: 'start',
6190
+ },
6191
+ {
6192
+ payload: {
6193
+ id: 'step1',
6194
+ status: 'running',
5981
6195
  },
5982
- {
5983
- "payload": {
5984
- "id": "step1",
5985
- "output": {
5986
- "result": "success1",
5987
- },
5988
- "status": "success",
6196
+ type: 'step-start',
6197
+ },
6198
+ {
6199
+ payload: {
6200
+ id: 'step1',
6201
+ endedAt: expect.any(Number),
6202
+ startedAt: expect.any(Number),
6203
+ payload: {},
6204
+ output: {
6205
+ result: 'success1',
5989
6206
  },
5990
- "type": "step-result",
6207
+ status: 'success',
5991
6208
  },
5992
- {
5993
- "payload": {
5994
- "id": "step1",
5995
- "metadata": {},
5996
- },
5997
- "type": "step-finish",
6209
+ type: 'step-result',
6210
+ },
6211
+ {
6212
+ payload: {
6213
+ id: 'step1',
6214
+ metadata: {},
5998
6215
  },
5999
- {
6000
- "payload": {
6001
- "id": "step2",
6002
- },
6003
- "type": "step-start",
6216
+ type: 'step-finish',
6217
+ },
6218
+ {
6219
+ payload: {
6220
+ id: 'step2',
6221
+ status: 'running',
6004
6222
  },
6005
- {
6006
- "payload": {
6007
- "id": "step2",
6008
- "output": {
6009
- "result": "success2",
6010
- },
6011
- "status": "success",
6223
+ type: 'step-start',
6224
+ },
6225
+ {
6226
+ payload: {
6227
+ id: 'step2',
6228
+ endedAt: expect.any(Number),
6229
+ startedAt: expect.any(Number),
6230
+ payload: {
6231
+ result: 'success1',
6012
6232
  },
6013
- "type": "step-result",
6014
- },
6015
- {
6016
- "payload": {
6017
- "id": "step2",
6018
- "metadata": {},
6233
+ output: {
6234
+ result: 'success2',
6019
6235
  },
6020
- "type": "step-finish",
6236
+ status: 'success',
6021
6237
  },
6022
- {
6023
- "payload": {
6024
- "runId": "test-run-id",
6025
- },
6026
- "type": "finish",
6238
+ type: 'step-result',
6239
+ },
6240
+ {
6241
+ payload: {
6242
+ id: 'step2',
6243
+ metadata: {},
6027
6244
  },
6028
- ]
6029
- `);
6245
+ type: 'step-finish',
6246
+ },
6247
+ {
6248
+ payload: {
6249
+ runId: 'test-run-id',
6250
+ },
6251
+ type: 'finish',
6252
+ },
6253
+ ]);
6030
6254
  // Verify execution completed successfully
6031
6255
  expect(executionResult.steps.step1).toMatchObject({
6032
6256
  status: 'success',
@@ -6099,10 +6323,11 @@ describe('MastraInngestWorkflow', () => {
6099
6323
 
6100
6324
  const app = await createHonoServer(mastra);
6101
6325
 
6102
- const srv = serve({
6326
+ const srv = (globServer = serve({
6103
6327
  fetch: app.fetch,
6104
6328
  port: (ctx as any).handlerPort,
6105
- });
6329
+ }));
6330
+ await resetInngest();
6106
6331
 
6107
6332
  const runId = 'test-run-id';
6108
6333
  let watchData: StreamEvent[] = [];
@@ -6110,7 +6335,7 @@ describe('MastraInngestWorkflow', () => {
6110
6335
  runId,
6111
6336
  });
6112
6337
 
6113
- await new Promise(resolve => setTimeout(resolve, 1000));
6338
+ await resetInngest();
6114
6339
 
6115
6340
  const { stream, getWorkflowState } = run.stream({ inputData: {} });
6116
6341
 
@@ -6123,11 +6348,11 @@ describe('MastraInngestWorkflow', () => {
6123
6348
 
6124
6349
  const executionResult = await getWorkflowState();
6125
6350
 
6126
- await new Promise(resolve => setTimeout(resolve, 1000));
6351
+ await resetInngest();
6127
6352
 
6128
6353
  srv.close();
6129
6354
 
6130
- expect(watchData.length).toBe(9);
6355
+ expect(watchData.length).toBe(11);
6131
6356
  expect(watchData).toMatchObject([
6132
6357
  {
6133
6358
  payload: {
@@ -6138,6 +6363,9 @@ describe('MastraInngestWorkflow', () => {
6138
6363
  {
6139
6364
  payload: {
6140
6365
  id: 'step1',
6366
+ startedAt: expect.any(Number),
6367
+ status: 'running',
6368
+ payload: {},
6141
6369
  },
6142
6370
  type: 'step-start',
6143
6371
  },
@@ -6147,6 +6375,7 @@ describe('MastraInngestWorkflow', () => {
6147
6375
  output: {
6148
6376
  result: 'success1',
6149
6377
  },
6378
+ endedAt: expect.any(Number),
6150
6379
  status: 'success',
6151
6380
  },
6152
6381
  type: 'step-result',
@@ -6159,12 +6388,43 @@ describe('MastraInngestWorkflow', () => {
6159
6388
  type: 'step-finish',
6160
6389
  },
6161
6390
  {
6162
- payload: {},
6391
+ payload: {
6392
+ id: expect.any(String),
6393
+ startedAt: expect.any(Number),
6394
+ status: 'waiting',
6395
+ payload: {
6396
+ result: 'success1',
6397
+ },
6398
+ },
6163
6399
  type: 'step-waiting',
6164
6400
  },
6401
+ {
6402
+ payload: {
6403
+ id: expect.any(String),
6404
+ endedAt: expect.any(Number),
6405
+ startedAt: expect.any(Number),
6406
+ status: 'success',
6407
+ output: {
6408
+ result: 'success1',
6409
+ },
6410
+ },
6411
+ type: 'step-result',
6412
+ },
6413
+ {
6414
+ type: 'step-finish',
6415
+ payload: {
6416
+ id: expect.any(String),
6417
+ metadata: {},
6418
+ },
6419
+ },
6165
6420
  {
6166
6421
  payload: {
6167
6422
  id: 'step2',
6423
+ payload: {
6424
+ result: 'success1',
6425
+ },
6426
+ startedAt: expect.any(Number),
6427
+ status: 'running',
6168
6428
  },
6169
6429
  type: 'step-start',
6170
6430
  },
@@ -6174,6 +6434,7 @@ describe('MastraInngestWorkflow', () => {
6174
6434
  output: {
6175
6435
  result: 'success2',
6176
6436
  },
6437
+ endedAt: expect.any(Number),
6177
6438
  status: 'success',
6178
6439
  },
6179
6440
  type: 'step-result',
@@ -6192,6 +6453,7 @@ describe('MastraInngestWorkflow', () => {
6192
6453
  type: 'finish',
6193
6454
  },
6194
6455
  ]);
6456
+
6195
6457
  // Verify execution completed successfully
6196
6458
  expect(executionResult.steps.step1).toMatchObject({
6197
6459
  status: 'success',
@@ -6264,10 +6526,11 @@ describe('MastraInngestWorkflow', () => {
6264
6526
 
6265
6527
  const app = await createHonoServer(mastra);
6266
6528
 
6267
- const srv = serve({
6529
+ const srv = (globServer = serve({
6268
6530
  fetch: app.fetch,
6269
6531
  port: (ctx as any).handlerPort,
6270
- });
6532
+ }));
6533
+ await resetInngest();
6271
6534
 
6272
6535
  const runId = 'test-run-id';
6273
6536
  let watchData: StreamEvent[] = [];
@@ -6275,7 +6538,7 @@ describe('MastraInngestWorkflow', () => {
6275
6538
  runId,
6276
6539
  });
6277
6540
 
6278
- await new Promise(resolve => setTimeout(resolve, 1000));
6541
+ await resetInngest();
6279
6542
 
6280
6543
  const { stream, getWorkflowState } = run.stream({ inputData: {} });
6281
6544
 
@@ -6295,7 +6558,7 @@ describe('MastraInngestWorkflow', () => {
6295
6558
 
6296
6559
  const executionResult = await getWorkflowState();
6297
6560
 
6298
- await new Promise(resolve => setTimeout(resolve, 1000));
6561
+ await resetInngest();
6299
6562
 
6300
6563
  srv.close();
6301
6564
 
@@ -6489,12 +6752,12 @@ describe('MastraInngestWorkflow', () => {
6489
6752
 
6490
6753
  const app = await createHonoServer(mastra);
6491
6754
 
6492
- const srv = serve({
6755
+ const srv = (globServer = serve({
6493
6756
  fetch: app.fetch,
6494
6757
  port: (ctx as any).handlerPort,
6495
- });
6758
+ }));
6496
6759
 
6497
- await new Promise(resolve => setTimeout(resolve, 1000));
6760
+ await resetInngest();
6498
6761
 
6499
6762
  const run = await promptEvalWorkflow.createRunAsync();
6500
6763
 
@@ -6678,12 +6941,12 @@ describe('MastraInngestWorkflow', () => {
6678
6941
 
6679
6942
  const app = await createHonoServer(mastra);
6680
6943
 
6681
- const srv = serve({
6944
+ const srv = (globServer = serve({
6682
6945
  fetch: app.fetch,
6683
6946
  port: (ctx as any).handlerPort,
6684
- });
6947
+ }));
6685
6948
 
6686
- await new Promise(resolve => setTimeout(resolve, 1000));
6949
+ await resetInngest();
6687
6950
 
6688
6951
  const run = await workflow.createRunAsync({
6689
6952
  runId: 'test-run-id',