@@ -64,23 +64,45 @@ test('Global state is isolated and maintained between activations', async (t) =>
64
64
} ) ;
65
65
} ) ;
66
66
67
- export async function propertyMutator ( ) : Promise < void > {
67
+ export async function sdkPropertyMutator ( ) : Promise < void > {
68
68
try {
69
69
( arrayFromPayloads as any ) . a = 1 ;
70
70
} catch ( err ) {
71
71
throw ApplicationFailure . fromError ( err ) ;
72
72
}
73
73
}
74
74
75
- test ( 'Module state is frozen' , withReusableContext , async ( t ) => {
75
+ test ( 'SDK Module state is frozen' , withReusableContext , async ( t ) => {
76
76
const { createWorker, taskQueue, env } = t . context ;
77
77
const worker = await createWorker ( ) ;
78
78
const err = ( await worker . runUntil (
79
- t . throwsAsync ( env . client . workflow . execute ( propertyMutator , { taskQueue, workflowId : randomUUID ( ) } ) )
79
+ t . throwsAsync ( env . client . workflow . execute ( sdkPropertyMutator , { taskQueue, workflowId : randomUUID ( ) } ) )
80
80
) ) as WorkflowFailedError ;
81
81
t . is ( err . cause ?. message , 'Cannot add property a, object is not extensible' ) ;
82
82
} ) ;
83
83
84
+ const someArr : number [ ] = [ ] ;
85
+
86
+ export async function modulePropertyMutator ( ) : Promise < number [ ] > {
87
+ someArr . push ( 1 ) ;
88
+ await sleep ( 1 ) ;
89
+ someArr . push ( 2 ) ;
90
+ return someArr ;
91
+ }
92
+
93
+ test ( 'Module state is isolated and maintained between activations' , async ( t ) => {
94
+ const { createWorker, taskQueue, env } = t . context ;
95
+ const worker = await createWorker ( ) ;
96
+ await worker . runUntil ( async ( ) => {
97
+ const [ res1 , res2 ] = await Promise . all ( [
98
+ env . client . workflow . execute ( modulePropertyMutator , { taskQueue, workflowId : randomUUID ( ) } ) ,
99
+ env . client . workflow . execute ( modulePropertyMutator , { taskQueue, workflowId : randomUUID ( ) } ) ,
100
+ ] ) ;
101
+ t . deepEqual ( res1 , [ 1 , 2 ] ) ;
102
+ t . deepEqual ( res2 , [ 1 , 2 ] ) ;
103
+ } ) ;
104
+ } ) ;
105
+
84
106
export async function sharedGlobalMutator ( ) : Promise < void > {
85
107
try {
86
108
( setTimeout as any ) . a = 1 ;
0 commit comments