Using 2.2.9 common pkg, fabproto6.google.protobuf.Timestamp.create is not a function
Hi, we are running a node webapp and recently upgraded the packages fabric-common and fabric-network to 2.2.9.
We started receiving this error:
"TypeError: fabproto6.google.protobuf.Timestamp.create is not a function
at buildCurrentTimestamp (/app/dist/node_modules/fabric-common/lib/Channel.js:553:56)
at Channel.buildChannelHeader (/app/dist/node_modules/fabric-common/lib/Channel.js:506:15)
at Endorsement.build (/app/dist/node_modules/fabric-common/lib/Proposal.js:291:41)
at Transaction.submit (/app/dist/node_modules/fabric-network/lib/transaction.js:191:21)
at MergeMapSubscriber.project (/app/dist/node_modules/@atmback-us/hlf-client/services/contracts/abstract-hlf-query-service.js:220:39)
at MergeMapSubscriber._tryNext (/app/dist/node_modules/rxjs/internal/operators/mergeMap.js:67:27)
at MergeMapSubscriber._next (/app/dist/node_modules/rxjs/internal/operators/mergeMap.js:57:18)
at MergeMapSubscriber.Subscriber.next (/app/dist/node_modules/rxjs/internal/Subscriber.js:66:18)
at TakeLastSubscriber._complete (/app/dist/node_modules/rxjs/internal/operators/takeLast.js:71:29)
at TakeLastSubscriber.Subscriber.complete (/app/dist/node_modules/rxjs/internal/Subscriber.js:78:18)"
After debugging it, appears the .create method really is undefined. I attempted adding fabric-protos pkg directly to my repo but still got the same error.
Is there something else I'm supposed to import?
For anyone who comes across this issue, I resolved it by adding a --root my_company_name CLI option to my protobuf generation steps. The issue was our proto package's Timestamp generated code was clobering fabric-protos generated protobuf code and we explicitly compile with --no-create causing the issue above.
This is because both our protos, and fab protos, were not setting the root flag, and thus both proto generated packages would use:
var $root = $protobuf.roots['default'] || ($protobuf.roots['default'] = {});
I suggest Fabric do the same and generate all their protos under their own root to prevent this clober
I see similar clober issue once before but not recently. would you mind give a Pull Request for it?
@davidkhala I couldn't find your scripts for generating the protos. If you point me to the script I could make the PR.
@davidkhala I couldn't find your scripts for generating the protos. If you point me to the script I could make the PR.
No, there was no need to have a script to get it fixed since it was fixed by maintainers once before. I am not quite sure if it is the same issue. The second sentense is also not intended to include any scripts but welcome to contribute.
There are some npm scripts in fabric-protos/package.json that are used to regenerate the protobufs published in the fabric-protos package