Skip to content

Commit 33af2ea

Browse files
committed
Completed self review
1 parent cce3ab9 commit 33af2ea

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

packages/test/src/test-sinks.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import test from 'ava';
33
import { v4 as uuid4 } from 'uuid';
44
import { 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';
66
import { SearchAttributes, WorkflowInfo } from '@temporalio/workflow';
77
import { UnsafeWorkflowInfo } from '@temporalio/workflow/lib/interfaces';
88
import { SdkComponent, TypedSearchAttributes } from '@temporalio/common';
@@ -21,6 +21,7 @@ class DependencyError extends Error {
2121

2222
if (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) => {

packages/worker/src/runtime.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ export class Runtime {
278278
if (Runtime._instance === this) delete Runtime._instance;
279279
(this as any).metricMeter = noopMetricMeter;
280280
this.teardownShutdownHook();
281+
// FIXME(JWH): I think we no longer need this, but will have to thoroughly validate.
281282
native.runtimeShutdown(this.native);
282283
this.flushLogs();
283284
} finally {

packages/workflow/src/metrics.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ export const metricMeter: MetricMeter = MetricMeterWithComposedTags.compose(
183183

184184
const info = activator.info;
185185
return getMetricTags({
186-
namespace: info.namespace,
187-
taskQueue: info.taskQueue,
186+
// namespace and taskQueue will be added by the Worker
188187
workflowType: info.workflowType,
189188
});
190189
},

0 commit comments

Comments
 (0)