Hello, I’m trying to run a simple workflow test and I find that there are linting and typescript errors when using the @temporalio/testing module.
So far, I’m faced with two issues and this post is about the second issue. The first issue is Workflow Testing Framework violates typescript checks? @temporalio/worker/lib/connection").NativeConnection is not assignable to type @temporalio/testing/node_modules/@temporalio/worker/lib/connection").NativeConnection
This topic’s issue is the error “duplicate name ‘ActivityHeartbeat’ in Namespace coresdk" when trying to execute my simple workflow test.
FAIL test/workflows/my-workflow.test.ts
● Test suite failed to run
duplicate name 'ActivityHeartbeat' in Namespace coresdk
1 | import { TestWorkflowEnvironment } from '@temporalio/testing';
> 2 | import { Worker, WorkerOptions } from '@temporalio/worker';
| ^
3 | import { v4 as uuid4 } from 'uuid';
4 | import { WorkflowCoverage } from '@temporalio/nyc-test-coverage';
at Namespace.add (node_modules/protobufjs/src/namespace.js:239:23)
at Root.add (node_modules/protobufjs/src/namespace.js:232:28)
at Root.addJSON (node_modules/protobufjs/src/namespace.js:172:16)
at Object.<anonymous> (node_modules/@temporalio/proto/protos/json-module.js:7:2)
at Object.<anonymous> (node_modules/@temporalio/proto/protos/root.js:8:23)
at Object.<anonymous> (node_modules/@temporalio/proto/protos/index.js:1:38)
at Object.<anonymous> (node_modules/@temporalio/worker/src/runtime.ts:23:1)
at Object.<anonymous> (node_modules/@temporalio/worker/src/connection.ts:5:1)
at Object.<anonymous> (node_modules/@temporalio/worker/src/index.ts:23:1)
at Object.<anonymous> (test/workflows/my-workflow.test.ts:2:1)
Any advice is appreciated. Thank you!
Same as in your other post, this is due to having multiple copies of packages. In this case, its about @temporalio/proto
. Possibly because you import different versions @temporalio/*
packages.
In my case, I was updating the temporal packages to v1.11.7 (from v.1.11.5) and I got this error when starting the app:
Error: duplicate name 'ActivityHeartbeat' in Namespace coresdk
at Namespace.add (/app/node_modules/protobufjs/src/namespace.js:239:23)
at Root.add (/app/node_modules/protobufjs/src/namespace.js:232:28)
at Root.addJSON (/app/node_modules/protobufjs/src/namespace.js:172:16)
at Object.<anonymous> (/app/node_modules/@temporalio/proto/protos/json-module.js:7:2)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Function.Module._load (node:internal/modules/cjs/loader:1024:12)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at Module.Hook.Module.require (/app/node_modules/dd-trace/packages/dd-trace/src/ritm.js:97:33)
After that, I left the @temporalio/proto package in v1.11.6 and received a similar error:
Error: duplicate name 'ActivityHeartbeat' in Namespace coresdk
at Namespace.add (/app/node_modules/protobufjs/src/namespace.js:239:23)
at Root.add (/app/node_modules/protobufjs/src/namespace.js:232:28)
at Root.addJSON (/app/node_modules/protobufjs/src/namespace.js:172:16)
at Object.<anonymous> (/app/node_modules/@temporalio/client/node_modules/@temporalio/proto/protos/json-module.js:7:2)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Function.Module._load (node:internal/modules/cjs/loader:1024:12)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at Module.Hook.Module.require (/app/node_modules/dd-trace/packages/dd-trace/src/ritm.js:97:33)
So, I added the resolution in the package.json as shown:
"@temporalio/proto": "1.11.6"
and leaving the rest packages in 1.11.7, and it worked. However, these warning appeared when running yarn:
warning Resolution field "@temporalio/proto@1.11.6" is incompatible with requested version "@temporalio/proto@1.11.7"
But the app is now starting well, so, I guess there’s an issue with proto
package in v1.11.7