Problem on running cross language workflow

Hi!
Just wrote a workflow using python SDK and wanted to use it in ts sdk. So I used protobuffs and followed this document:

But after I created json-module.js by this command:

pbjs -t json-module -w commonjs -o protos/json-module.js protos/*.proto

The problem is here when I create a this file I get following error and don’t know what to do. Everything seems to be okay.

Error Message:

TypeError: ($protobuf.roots.default || (intermediate value)(intermediate value)).addJSON is not a function

json-module.js:

const $protobuf = require("protobufjs/light");

const $root =
  ($protobuf.roots["default"] ||
  ($protobuf.roots["default"] = new $protobuf.Root())).addJSON({
   ....
});

module.exports = $root;

Thanks for any help.

So I used protobuffs

Are you using the protobuffs for workflow data inputs?
I think you can use just default JSON data converters for this.

1 Like

Hi dear @tihomir !

Yea, the workflow in python sdk, uses protobuffs as data inputs!

Tagging @bergundy :slight_smile:

Do you have any other generated protobufs in this TS repo? If so, the “default” root namespace might be clashing. In which case the fix would be adding --root rezaxd

If that doesn’t help, does the protobuf sample work for you? If yes, can you tell what the differences are between it and your project? samples-typescript/protobufs at main · temporalio/samples-typescript · GitHub

No I don’t have any other PBs.

As I said I followed that document and the repo that related to this document (= the repo that u send me the link of it).

Everything is same, except .proto file and I just declared 2 messages. And weird thing for me is that I can do everything json-module.js in node repl without any errors (I don’t know said that maybe it helps).

Thanks so much.

I would try adding root to pbjs anyway, just to check. Not sure what the issue is, but I’d be happy to take a look at your repo, if you can share it. I’m @lorensr on GH.

Currently I can’t publish the repo.
But as I said everything is same to this repo/doc.
The difference is my .proto file:

syntax = "proto3";

package pkgName;

message InnerMessage {
  string context = 1;
  string name = 3;
}

message OutterMeesage {
  InnerMessage msg_f = 1;
  InnerMessage msg_l = 2;
}

That .proto should be fine. If you can reproduce, I can look into it more—either taking out all the proprietary stuff from your repo, or modifying the sample to be more like your repo until you get the error.

Deleted node_modules folder and run npm i again, seems there is no problem and works properly.

I kinda feel sorry for opening this topic.

Thank u for helping me! <3