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

TypeError on chaincode start with fabric-shim >=2.5.1

Open bestbeforetoday opened this issue 2 years ago • 0 comments
trafficstars

A mismatch of @grpc/grpc-js versions between the @hyperledger/fabric-protos package and fabric-shim (version >=2.5.1) appears to cause the following error when the chaincode container is started:

TypeError: Channel credentials must be a ChannelCredentials object

A work-around appears to be to run npm dedupe following npm install (or as a postinstall npm script action).

Here are the Docker logs collected from a failure of the asset-transfer-sbe TypeScript chaincode from the fabric-samples repository:

+ CHAINCODE_DIR=/usr/local/src
+ cd /usr/local/src
+ npm start -- --peer.address peer0.org1.example.com:7052

> [email protected] start
> fabric-chaincode-node start --peer.address peer0.org1.example.com:7052

2023-09-17T14:26:14.091Z info [c-api:./lib/annotations/object.js]                 @Object args: Target -> %s "Function"
2023-09-17T14:26:14.092Z info [c-api:./lib/annotations/transaction.js]            @Transaction args: "Property Key -> CreateAsset, Commit -> true,","Target ->","AssetContract"
2023-09-17T14:26:14.093Z info [c-api:./lib/annotations/transaction.js]            @Transaction args: "Property Key -> ReadAsset, Commit -> false,","Target ->","AssetContract"
2023-09-17T14:26:14.093Z info [c-api:./lib/annotations/transaction.js]            @Transaction args: "Property Key -> UpdateAsset, Commit -> true,","Target ->","AssetContract"
2023-09-17T14:26:14.093Z info [c-api:./lib/annotations/transaction.js]            @Transaction args: "Property Key -> DeleteAsset, Commit -> true,","Target ->","AssetContract"
2023-09-17T14:26:14.093Z info [c-api:./lib/annotations/transaction.js]            @Transaction args: "Property Key -> TransferAsset, Commit -> true,","Target ->","AssetContract"
2023-09-17T14:26:14.094Z info [c-api:./lib/annotations/info.js]                   @Info args: "Info -> [object Object],","Target ->","AssetContract"
2023-09-17T14:26:14.101Z info [c-api:contracts-spi/bootstrap.js]                  No metadata file supplied in contract, introspection will generate all the data
2023-09-17T14:26:14.154Z info [c-api:lib/handler.js]                              Creating new Chaincode Support Client for peer comminications
fabric-chaincode-node start --peer.address localhost:7051 --chaincode-id-name mycc

Options:
      --help                                  Show help  [boolean]
  -v, --version                               Show version number  [boolean]
      --peer.address  [string] [required]
      --grpc.max_send_message_length  [number] [default: -1]
      --grpc.max_receive_message_length  [number] [default: -1]
      --grpc.keepalive_time_ms  [number] [default: 110000]
      --grpc.http2.min_time_between_pings_ms  [number] [default: 110000]
      --grpc.keepalive_timeout_ms  [number] [default: 20000]
      --grpc.http2.max_pings_without_data  [number] [default: 0]
      --grpc.keepalive_permit_without_calls  [number] [default: 1]
      --ssl-target-name-override  [string]
      --chaincode-id-name  [string] [required]
      --module-path  [string] [default: "/usr/local/src"]

TypeError: Channel credentials must be a ChannelCredentials object
    at new ChannelImplementation (/usr/local/src/node_modules/@grpc/grpc-js/build/src/channel.js:28:19)
    at new Client (/usr/local/src/node_modules/@grpc/grpc-js/build/src/client.js:65:36)
    at new ServiceClientImpl (/usr/local/src/node_modules/@grpc/grpc-js/build/src/make-client.js:58:5)
    at new ChaincodeSupportClient (/usr/local/src/node_modules/fabric-shim/lib/handler.js:247:24)
    at Shim.start (/usr/local/src/node_modules/fabric-shim/lib/chaincode.js:129:24)
    at Bootstrap.register (/usr/local/src/node_modules/fabric-shim/lib/contract-spi/bootstrap.js:43:18)
    at Bootstrap.bootstrap (/usr/local/src/node_modules/fabric-shim/lib/contract-spi/bootstrap.js:56:25)
    at async exports.handler (/usr/local/src/node_modules/fabric-shim/lib/cmds/startCommand.js:38:5)

bestbeforetoday avatar Sep 17 '23 15:09 bestbeforetoday