22import test from 'ava' ;
33import { v4 as uuid4 } from 'uuid' ;
44import { Connection , WorkflowClient } from '@temporalio/client' ;
5- import { DefaultLogger , InjectedSinks , Runtime , WorkerOptions , LogEntry } from '@temporalio/worker' ;
5+ import { DefaultLogger , InjectedSinks , Runtime , WorkerOptions , LogEntry , NativeConnection } from '@temporalio/worker' ;
66import { SearchAttributes , WorkflowInfo } from '@temporalio/workflow' ;
77import { UnsafeWorkflowInfo } from '@temporalio/workflow/lib/interfaces' ;
88import { SdkComponent , TypedSearchAttributes } from '@temporalio/common' ;
@@ -21,6 +21,7 @@ class DependencyError extends Error {
2121
2222if ( RUN_INTEGRATION_TESTS ) {
2323 const recordedLogs : { [ workflowId : string ] : LogEntry [ ] } = { } ;
24+ let nativeConnection : NativeConnection ;
2425
2526 test . before ( async ( _ ) => {
2627 await registerDefaultCustomSearchAttributes ( await Connection . connect ( { } ) ) ;
@@ -31,6 +32,17 @@ if (RUN_INTEGRATION_TESTS) {
3132 recordedLogs [ workflowId ] . push ( entry ) ;
3233 } ) ,
3334 } ) ;
35+
36+ // FIXME(JWH): At some point, tests in this file ends up creating a situation where we no longer have any
37+ // native resource tracked by the lang side Runtime object, so the lang Runtime tries to shutdown itself,
38+ // but in the mean time, another test tries to create another resource. which results in a rust side
39+ // finalization error. Holding on to a nativeConnection object avoids that situation. That's a dirty hack.
40+ // Proper fix will be implemented in a distinct PR.
41+ nativeConnection = await NativeConnection . connect ( { } ) ;
42+ } ) ;
43+
44+ test . after . always ( async ( ) => {
45+ await nativeConnection . close ( ) ;
3446 } ) ;
3547
3648 test ( 'Worker injects sinks' , async ( t ) => {
0 commit comments