Important: fabric-chaincode-node failing


Matthew White
 

In the last 48 hours a lot of the chaincode node builds have failed; we’ve identified the cause for this – it’s a defect in the grpc-js library that the Fabric modules use.

An issue in fabric-chaincode-node has raised for information; note that ideally a fix is needed in grpc-js but there are workarounds we can apply.

Below is the text from issue https://github.com/hyperledger/fabric-chaincode-node/issues/372

Any questions please post to that issue.

Thanks Matthew.

---

When using a NodeJS chaincode, the chaincode container will start but fail on the first transaction. In either the peer logs or chaincode logs there will be errors about the "chat stream being closed or cancelled."

The peer-chaincode connection will be dropped and the chaincode container will also exit.

Affected
We've seen this affect 2.2 2.4 and the 2.5 release; note that this is an issue pulling in an updated dependency of the chaincode-node libraries. Chaincode that is already running won't be affected.

Cause

grpc-js, a dependency of fabric-shim for javascript chaincode has had a recent update that appears to have broken fabric-shim. New installs will pick up this latest grpc-js dependency and is causing javascript chaincodes to terminate.

The 1.8.2 grpc-js release is problematic release; 1.8.1 is the last good one.

grpc-js issue grpc/grpc-node#2318

Workaround

If affected the best workaround is to install a specific version of grpc-js in your own chaincode's package.json

npm install --save @grpc/grpc-js@1.8.1

Double check the package.json has the version of exactly 1.8.1 - ensure there are no ^ or ~ or other prefix.
This should ensure that when the dependencies are resolved the 1.8.1 will be used. Note that we've not tested with all node module installers. We're confident this approach works with node16's npm.

It is also recommended to use the npm shrinkwrap mechanism to lock down as many dependencies as possible when deploying.

Fixes

  • Hopefully a fix will be made available with grpc-js at some point.
  • The release-2.5 branch of fabric-chaincode-node has locked grpc-js to 1.8.1
  • We will see if it's possible to do patch releases of 2.4/2.2 fabric-chaincode-node. The chaincode

 

Unless otherwise stated above:

IBM United Kingdom Limited
Registered in England and Wales with number 741598
Registered office: PO Box 41, North Harbour, Portsmouth, Hants. PO6 3AU