fabric-sdk-node icon indicating copy to clipboard operation
fabric-sdk-node copied to clipboard

Using 2.2.9 common pkg, fabproto6.google.protobuf.Timestamp.create is not a function

Open gallak87 opened this issue 4 years ago • 5 comments

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?

gallak87 avatar Aug 27 '21 23:08 gallak87

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

gallak87 avatar Aug 28 '21 15:08 gallak87

I see similar clober issue once before but not recently. would you mind give a Pull Request for it?

davidkhala avatar Sep 07 '21 03:09 davidkhala

@davidkhala I couldn't find your scripts for generating the protos. If you point me to the script I could make the PR.

gallak87 avatar Sep 11 '21 14:09 gallak87

@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.

davidkhala avatar Sep 13 '21 02:09 davidkhala

There are some npm scripts in fabric-protos/package.json that are used to regenerate the protobufs published in the fabric-protos package

bestbeforetoday avatar Sep 21 '21 17:09 bestbeforetoday