Worker error with .mul is not a function

We recommend not using the temporalio meta package anymore, due to issues like this. Instead, install all the packages you use directly:

npm install @temporalio/client @temporalio/worker @temporalio/workflow @temporalio/activity

@loren So we use yarn, but we have it installed separately like that already. Our package.json for example lists the packages separately.

    "@temporalio/common": "~1.0.1",
    "@temporalio/worker": "~1.0.1",
    "@temporalio/workflow": "~1.0.1",

I’ve seen protobuf use number instead of long when running in a browser-like environment (VS Code webview) but have never seen this happen in Node.js.

Are you bundling your worker or have any other unconventional build steps?
Maybe some custom fields in your package.json?

It appears that protobufjs is checking at runtime either Long is available. If it isn’t, then it creates regular objects that looks similar to Long’s structures, but without any method on it. Unfortunately, Yarn’s PnP somehow breaks the way protobufjs does this check at runtime. I’m still trying to understand why and how we can fix this.

@rifruf In the mean time, if you want to try other things, here’s one… Not sure if it will works, but you might be able to make progress by adding the following to your .yarnrc.yml file:

packageExtensions:
  "@temporalio/client@*":
    dependencies:
      long: "5.2"
  "@temporalio/worker@*":
    dependencies:
      long: "5.2"
  "@temporalio/workflow@*":
    dependencies:
      long: "5.2"
  "@temporalio/activity@*":
    dependencies:
      long: "5.2"
  "@temporalio/common@*":
    dependencies:
      long: "5.2"
  "@temporalio/proto@*":
    dependencies:
      long: "5.2"
  "@temporalio/core-bridge@*":
    dependencies:
      long: "5.2"
  "@temporalio/internal-non-workflow-common@*":
    dependencies:
      long: "5.2"
  "protobufjs@*":
    dependencies:
      long: "5.2"
  "@grpc/proto-loader@*":
    dependencies:
      long: "5.2"
  "@grpc/grpc-js@*":
    dependencies:
      long: "5.2"

Good news, I nailed down the culprit.

I’ll work a PR to fix this, but in the mean time, you can resolve the issue in your own environment by adding the following to your .yarnrc.yml file (forget all previous additions I suggested):

packageExtensions:
  "@protobufjs/inquire@*":
    dependencies:
      long: "5.2"
2 Likes