Have a workflow that executes properly with local workers. When trying to do this in my production cluster with deployed workers, I’m getting the following error, does anyone have any ideas on what could be happening
2022-08-04T03:32:56.766Z [ERROR] Failed to activate workflow {
runId: 'b2fd073b-42a6-40ce-b719-1468474d7f2c',
error: TypeError: (seconds || long_1.default.UZERO).mul is not a function
at tsToMs (/opt/app-root/src/.yarn/cache/@temporalio-internal-workflow-common-npm-1.0.0-rc.1-b66f54d7d6-4272b669aa.zip/node_modules/@temporalio/internal-workflow-common/lib/time.js:30:10)
at /opt/app-root/src/.yarn/cache/@temporalio-worker-npm-1.0.0-rc.1-2998f0d7a7-147819cf17.zip/node_modules/@temporalio/worker/lib/worker.js:664:90
at async /opt/app-root/src/.yarn/cache/@temporalio-worker-npm-1.0.0-rc.1-2998f0d7a7-147819cf17.zip/node_modules/@temporalio/worker/lib/tracing.js:65:20
at async /opt/app-root/src/.yarn/cache/@temporalio-worker-npm-1.0.0-rc.1-2998f0d7a7-147819cf17.zip/node_modules/@temporalio/worker/lib/worker.js:593:28,
workflowExists: false
}
Seems like some type of dependency that should exist doesn’t exist here?
You mention your workflows work correctly in development… What are the differences in how you prepare your code for production vs development? i.e. ts-node or not? pnp? bundleWorkflows() being called explicitly?
Actually upon further inspection, it seems we just use pnp and do a require.resolve instead of bundling it in production. Going to try bundling it in production.
Also wanted to confirm that this mul function is something that should be provided by the long package? I had tried downloading the Temporal Typescript SDK locally and looking at the types, but for some reason couldn’t get the package to build and install properly, so wasn’t able to determine the types.
bash-4.4$ yarn info long
└─ long@npm:5.2.0
└─ Version: 5.2.0
which implies we’re using the correct version.
However, if I drill down on what is using the one long package with version 4.0.0, which seems to be protobufjs@npm:6.11.3, I see that the only package I have that uses that as a dependency is proto3-json-serializer@npm:^1.0.2, and in turn, the only package that has proto3-json-serializer@npm:^1.0.2 as a dependency is "@temporalio/common@npm:^1.0.1, @temporalio/common@npm:~1.0.1":. As I’m already on the latest version of temporal, I don’t see how to ensure that long 4.0.0 isn’t present in the yarn cache whatsoever.
@loren do you have any other suggestions or information I could provide? I’ve still been unable to repro this, as it works fine locally, and only runs into this in my deployments. Thank you!
it could be that tsc get somehow confused about the actual structure of the Long object… long@5.2.0 has been converted to ESM. tsc needs to injects some adaptation code to correctly work with ESM modules when running in non-ESM context. What if tsc considers it doesn’t need to do that work on long because it believes it is the 4.0.0, but at runtime, it actually load the 5.2.0 which needs those adaptations…
Gotcha thanks for the quick reply, I can give that a try. What’s the proper way to pin proto3-json-serializer to 1.0.3, is it just by specifying proto3-json-serializer: "^1.0.3", in my package.json? Just curious if you had smth specific in mind.
If that doesn’t help, would it a possibility for you test your deployment with the following addition to your .yarnrc.yml file:
pnpMode: loose
I strongly believe that PnP is somehow involved in this issue, though I can’t figure out why… This flag still enables PnP, but changes its resolution algorithm to be more compatible with that of NPM. If it works, it would at least confirm that we are indeed looking in the right direction…
So those suggestions didn’t seem to fix the problem, but after some help, the problem seems to be the way that we build our Docker containers that run these workers in our deployments. Specifically, we have a line where we do RUN yarn workspaces focus --production @temporal-workflows, causing the container to only install dependencies, but not devDependencies. We tried running RUN yarn workspaces focus --all @scale/temporal-workflows instead, which seems to work.
We tried moving all the devDependencies to dependencies in our repositories package.json files, but this still didn’t fix the issue, so it led us to believe that it’s a possibility the error stems from within the temporalio typescript SDK package not having a dependency listed (possibly long listed here sdk-typescript/package.json at main · temporalio/sdk-typescript · GitHub). We also had a similar problem earlier where for some reason long had to be specified as a dependency in our root package.json, even though we were only using temporalio in a package located within our packages/ folder (and specifying long in that package’s package.json didn’t work either).
Curious if you guys have suggestions moving forward about how to best remedy this/test if this is the case? We were running into issues building/installing your typescript SDK package locally (so that we could use this) to verify.