hurley icon indicating copy to clipboard operation
hurley copied to clipboard

`hurl new` running in UnhandledPromiseRejection | Windows

Open PeterMerkert opened this issue 5 years ago • 17 comments

I am running on Windows (10 pro) and simply executing hurl new will result in an UnhandledPromiseRejection as follows:

[hurley] - Hurley collects anonymous usage statistics to improve the tool over time
[hurley] - About to create binaries
[hurley] - Created and saved binaries
[hurley] - About to run binaries
[hurley] - Ran binaries
[hurley] - About to create configtxyaml
[hurley] - Created and saved configtxyaml
[hurley] - About to create cryptoconfigyaml
[hurley] - Created and saved cryptoconfigyaml
[hurley] - About to create cryptoconfigsh
[hurley] - Created and saved cryptoconfigsh
[hurley] - Running cryptoconfigsh
[hurley] - Ran cryptoconfigsh
[hurley] - Building compose
(node:2944) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'find' of undefined
    at DockerComposeYamlGenerator.<anonymous> (C:\Users\NeevoLima\AppData\Roaming\npm\node_modules\@worldsibu\hurley\dist\generators\dockercompose.yaml.js:44:42)
    at step (C:\Users\NeevoLima\AppData\Roaming\npm\node_modules\@worldsibu\hurley\node_modules\tslib\tslib.js:133:27)
    at Object.next (C:\Users\NeevoLima\AppData\Roaming\npm\node_modules\@worldsibu\hurley\node_modules\tslib\tslib.js:114:57)
    at fulfilled (C:\Users\NeevoLima\AppData\Roaming\npm\node_modules\@worldsibu\hurley\node_modules\tslib\tslib.js:104:62)
(node:2944) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2944) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I have docker installed and docker-compose is available on my command line. What am I missing?

PeterMerkert avatar May 08 '19 10:05 PeterMerkert

Hi @PeterMerkert

Doesn't look like an error specifically there, at that step it's looking for some files that were generated previously and not finding them. Fabric does have some problems with Windows sometimes, can you retry running the command with admin permissions?

walmon avatar May 08 '19 13:05 walmon

Thanks @walmon for the help. Not sure which other steps to follow, other than npm i -g @worldsibu/hurley from your README. I did that. The node_modules are located in the user directory, thus no need for admin access. Though I also gave that a try.

I have yesterday tried to debug the problem further. I see, that is apparently tries to load some certificates. I also see that it maybe tries to load them from the %HOME%\hyperledger-fabric-network directory. This looks as follows: 2019-05-09 16_12_22-Window From the plain source code sight, it seem missing some folders in there.

It sounds for me, that I am missing some Hyperledger dependencies then. I have downloaded the docker containers for Hyperledger. Maybe you can pin points me, which Hyperledger Fabric setup steps I have to do before hurley would execute?

PeterMerkert avatar May 09 '19 13:05 PeterMerkert

According to Fabric's official page: https://hyperledger-fabric.readthedocs.io/en/release-1.4/prereqs.html#windows-extras

Containers are downloaded by Hurley, so no need to do that.

Also, the permissions I was telling you is precisely because sometimes that path %HOME%\hyperledger-fabric-network gives issues.

walmon avatar May 09 '19 13:05 walmon

Hi @walmon , I went through all prerequisites of Hyperledger Fabric. Unfortunately, nothing has changed. The output as in my initial post.

I think I am listing all possible requirements: docker --version => Docker version 18.09.2, build 6247962 docker-compose --version => docker-compose version 1.23.2, build 1110ad01 I have added my full C drive as a shared folder in docker. go version => go version go1.12.5 windows/amd64 echo $Env:GOPATH => C:\Users\NeevoLima\go npm -v => 5.3.0 node -v => v8.4.0 python --verison => Python 2.7.15 npm list -g --depth 0 =>

C:\Program Files\nodejs
+-- @worldsibu/[email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

I am executing all commands in administration mode on powershell. Am am running Windows 10 64 bit.

When running the Hyperledger Fabric Install Samples, Binaries and Docker Images, I get a folder containing a subfolder named basic-network. That looks as follows: 2019-05-10 08_32_40-basic-network

I am quite clueless to be honest.

PeterMerkert avatar May 10 '19 05:05 PeterMerkert

I am facing the exact same issue. Is there any resolution. I am on Windows 10 (admin mode)

crazycoolY avatar Sep 05 '19 09:09 crazycoolY

@crazycoolY can you provide the full error log printed in your console?

diestrin avatar Sep 05 '19 14:09 diestrin

I am also facing the exact same issues, in both ubuntu 16 .0.4 and windows 10.

`PS E:\Hyperledger\car> npm run env:restart

[email protected] env:restart E:\Hyperledger\car hurl new

[hurley] - Hurley collects anonymous usage statistics to improve the tool over time [hurley] - About to create binaries [hurley] - Created and saved binaries [hurley] - About to run binaries [hurley] - Ran binaries [hurley] - About to create configtxyaml [hurley] - Created and saved configtxyaml [hurley] - About to create cryptoconfigyaml [hurley] - Created and saved cryptoconfigyaml [hurley] - About to create cryptoconfigsh [hurley] - Created and saved cryptoconfigsh [hurley] - Running cryptoconfigsh [hurley] - Ran cryptoconfigsh [hurley] - Building compose (node:16532) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'find' of undefined at DockerComposeYamlGenerator. (C:\Users\hp-4\AppData\Roaming\npm\node_modules@worldsibu\hurley\dist\generators\dockercompose.yaml.js:44:42) at step (C:\Users\hp-4\AppData\Roaming\npm\node_modules@worldsibu\hurley\node_modules\tslib\tslib.js:136:27) at Object.next (C:\Users\hp-4\AppData\Roaming\npm\node_modules@worldsibu\hurley\node_modules\tslib\tslib.js:117:57) at fulfilled (C:\Users\hp-4\AppData\Roaming\npm\node_modules@worldsibu\hurley\node_modules\tslib\tslib.js:107:62) at (node:16532) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:16532) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. PS E:\Hyperledger\car> `

saurabkunwar avatar Sep 16 '19 07:09 saurabkunwar

Hello, any news on this? I'm following the example on medium and I'm getting the same above, with some minor differences: (node:13896) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'find' of undefined at DockerComposeYamlGenerator.<anonymous> (C:\dev\convector\fabcar\node_modules\@worldsibu\hurley\dist\generators\dockercompose.yaml.js:44:42) at step (C:\dev\convector\fabcar\node_modules\tslib\tslib.js:136:27) at Object.next (C:\dev\convector\fabcar\node_modules\tslib\tslib.js:117:57) at fulfilled (C:\dev\convector\fabcar\node_modules\tslib\tslib.js:107:62) at <anonymous> (node:13896) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:13896) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

lawrenceong001 avatar Oct 30 '19 03:10 lawrenceong001

There seems to be a problem with the path resolution in Windows, the problem is either in here or here. Unfortunately, I don't have access to a Windows environment to be able to test. Any help on this will be appreciated

diestrin avatar Oct 30 '19 14:10 diestrin

Hello , we are also facing the issue on Windows 10 with Admin access . kindly please if any one have solution , please post it here .

spsingh559 avatar Nov 06 '19 14:11 spsingh559

I am also facing the same issue ;(

koptan avatar Nov 06 '19 21:11 koptan

Hi! I am facing the same problem! And I can't find a solution! Would you help me? PS C: \ Users \ Felipe Duarte \ Desktop \ 2 \ commercial> hurl new [hurley] - Hurley collects anonymous usage statistics to improve the tool over time [hurley] - About to create binaries [hurley] - Created and saved binaries [hurley] - About to run binaries [hurley] - Ran binaries [hurley] - About to create configtxyaml [hurley] - Created and saved configtxyaml [hurley] - About to create cryptoconfigyaml [hurley] - Created and saved cryptoconfigyaml [hurley] - About to create cryptoconfigsh [hurley] - Created and saved cryptoconfigsh [hurley] - Running cryptoconfigsh [hurley] - Ran cryptoconfigsh [hurley] - Building make up (node: 5604) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'find' of undefined     at DockerComposeYamlGenerator. (C: \ Users \ Felipe Duarte \ AppData \ Roaming \ npm \ node_modules \ @worldsibu \ hurley \ dist \ generators \ dockercompose.yaml.js: 44: 42)     at step (C: \ Users \ Felipe Duarte \ AppData \ Roaming \ npm \ node_modules \ @worldsibu \ hurley \ node_modules \ tslib \ tslib.js: 136: 27)     at Object.next (C: \ Users \ Felipe Duarte \ AppData \ Roaming \ npm \ node_modules \ @worldsibu \ hurley \ node_modules \ tslib \ tslib.js: 117: 57)     at fulfilled (C: \ Users \ Felipe Duarte \ AppData \ Roaming \ npm \ node_modules \ @worldsibu \ hurley \ node_modules \ tslib \ tslib.js: 107: 62) (node: 5604) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside an async function without a catch block, or by rejecting a promise which was not handled with .catch (). (rejection id: 1) (node: 5604) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

felipeduartedelima avatar Nov 25 '19 13:11 felipeduartedelima

This happens on Ubuntu 18.06 too.

It would be awesome if those promises would be handled to output at least some more useful error context.

This is my output (after instrumenting adding a log write before the exception is thrown):

===> List out hyperledger docker images
{ [String: 'Installing Hyperledger Fabric binaries\nBinaries exist already\nChecking IMAGES\n===> Pulling fabric Images\n==> FABRIC IMAGE: peer\n\n1.4.0: Pulling from hyperledger/fabric-peer\nDigest: sha256:9707c97f787de1d4d6dd60994d6b8ea2e5cc28b0f42e6849df3fb41c64b41372\nStatus: Image is up to date for hyperledger/fabric-peer:1.4.0\n==> FABRIC IMAGE: orderer\n\n1.4.0: Pulling from hyperledger/fabric-orderer\nDigest: sha256:644265186b4887c7d9dcb91895124ccead3c0125c2c4f9eadc421dc9555d7495\nStatus: Image is up to date for hyperledger/fabric-orderer:1.4.0\n==> FABRIC IMAGE: tools\n\n1.4.0: Pulling from hyperledger/fabric-tools\nDigest: sha256:aee256916d0cb938d8023fa32ed2745991d32cfe79018e360f1720707ebfbdb5\nStatus: Image is up to date for hyperledger/fabric-tools:1.4.0\n===> Pulling fabric ca Image\n==> FABRIC CA IMAGE\n\n1.4.0: Pulling from hyperledger/fabric-ca\nDigest: sha256:c1dce534d9e9202697e0aaad7c5521d958700fda0b05127dafb9333c22e15f74\nStatus: Image is up to date for hyperledger/fabric-ca:1.4.0\n===> Pulling thirdparty docker images\n==> THIRDPARTY DOCKER IMAGE: couchdb\n\n0.4.14: Pulling from hyperledger/fabric-couchdb\nDigest: sha256:021c7e4a5047432d892fbdf7d5220d3049ff4e8b436fd481bb08e41871f1aac7\nStatus: Image is up to date for hyperledger/fabric-couchdb:0.4.14\n\n===> List out hyperledger docker images\n']
  stdout:
   'Installing Hyperledger Fabric binaries\nBinaries exist already\nChecking IMAGES\n===> Pulling fabric Images\n==> FABRIC IMAGE: peer\n\n1.4.0: Pulling from hyperledger/fabric-peer\nDigest: sha256:9707c97f787de1d4d6dd60994d6b8ea2e5cc28b0f42e6849df3fb41c64b41372\nStatus: Image is up to date for hyperledger/fabric-peer:1.4.0\n==> FABRIC IMAGE: orderer\n\n1.4.0: Pulling from hyperledger/fabric-orderer\nDigest: sha256:644265186b4887c7d9dcb91895124ccead3c0125c2c4f9eadc421dc9555d7495\nStatus: Image is up to date for hyperledger/fabric-orderer:1.4.0\n==> FABRIC IMAGE: tools\n\n1.4.0: Pulling from hyperledger/fabric-tools\nDigest: sha256:aee256916d0cb938d8023fa32ed2745991d32cfe79018e360f1720707ebfbdb5\nStatus: Image is up to date for hyperledger/fabric-tools:1.4.0\n===> Pulling fabric ca Image\n==> FABRIC CA IMAGE\n\n1.4.0: Pulling from hyperledger/fabric-ca\nDigest: sha256:c1dce534d9e9202697e0aaad7c5521d958700fda0b05127dafb9333c22e15f74\nStatus: Image is up to date for hyperledger/fabric-ca:1.4.0\n===> Pulling thirdparty docker images\n==> THIRDPARTY DOCKER IMAGE: couchdb\n\n0.4.14: Pulling from hyperledger/fabric-couchdb\nDigest: sha256:021c7e4a5047432d892fbdf7d5220d3049ff4e8b436fd481bb08e41871f1aac7\nStatus: Image is up to date for hyperledger/fabric-couchdb:0.4.14\n\n===> List out hyperledger docker images\n',
  stderr: '',
  code: 1,
  cat: [Function: bound ],
  exec: [Function: bound ],
  grep: [Function: bound ],
  head: [Function: bound ],
  sed: [Function: bound ],
  sort: [Function: bound ],
  tail: [Function: bound ],
  to: [Function: bound ],
  toEnd: [Function: bound ],
  uniq: [Function: bound ] }
[hurley] - Found error while running script!
(node:17553) UnhandledPromiseRejectionWarning: Error: Errors found in script, stopping execution
    at Object.<anonymous> (/myapp/node_modules/@worldsibu/hurley/dist/utils/sysWrapper.js:119:27)
    at step (/myapp/node_modules/tslib/tslib.js:136:27)
    at Object.next (/myapp/node_modules/tslib/tslib.js:117:57)
    at /myapp/node_modules/tslib/tslib.js:110:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/myapp/node_modules/tslib/tslib.js:106:16)
    at Object.execContent (/myapp/node_modules/@worldsibu/hurley/dist/utils/sysWrapper.js:112:24)
    at DownloadFabricBinariesGenerator.BaseGenerator.run (/myapp/node_modules/@worldsibu/hurley/dist/generators/base.js:18:40)
    at NetworkCLI.<anonymous> (/myapp/node_modules/@worldsibu/hurley/dist/cli.js:191:53)
    at step (/myapp/node_modules/tslib/tslib.js:136:27)
(node:17553) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:17553) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code

hbobenicio avatar Feb 12 '20 19:02 hbobenicio

I've discovered that the error is caused by this (at least in my case):

echo "===> List out hyperledger docker images"
docker images | grep hyperledger*

from hyperledger-fabric-network/binaries.sh

but the thing is that hurley new seems to dynamically generate that shellscript

this command is sent to "bin/bash". Notice the wildcard misuse:

docker images | grep hyperledger*

it sould be escaped like this

docker images | grep 'hyperledger*'

Probably this is the issue: https://github.com/worldsibu/hurley/blob/develop/src/generators/downloadFabricBinaries.ts

hbobenicio avatar Feb 12 '20 19:02 hbobenicio

Just antecipating that, fixing this would still face another problem. It's probably better to describe it in another issue.... but here it goes anyway (if your facing the same problem as me, it could help):

[hurley] - Running cryptoconfigsh
[hurley] - 
  #!/bin/bash
  set -e
  ROOT_DIR=/dir with space/myapp/node_modules/@worldsibu/hurley

# ... truncated ...
{ [String: '']
  stdout: '',
  stderr: '/bin/bash: linha 3: with: comando não encontrado\n',
  code: 127,
  cat: [Function: bound ],
  exec: [Function: bound ],
  grep: [Function: bound ],
  head: [Function: bound ],
  sed: [Function: bound ],
  sort: [Function: bound ],
  tail: [Function: bound ],
  to: [Function: bound ],
  toEnd: [Function: bound ],
  uniq: [Function: bound ] }
[hurley] - Found error while running script!
(node:25055) UnhandledPromiseRejectionWarning: Error: Errors found in script, stopping execution
    at Object.<anonymous> (/dir with space/myapp/node_modules/@worldsibu/hurley/dist/utils/sysWrapper.js:119:27)

the shellscript generated is not wrapping it's value with a double quotes ", resulting in a broken shellscript if your are using directories with spaces.

It would be awesome if someone could review bash best practicies on those shellscripts. They are very messy.

this is the cause later then: https://github.com/worldsibu/hurley/blob/develop/src/generators/cryptofilesgenerator.sh.ts (no double quotes on variables such as ROOT_DIR)

hbobenicio avatar Feb 12 '20 20:02 hbobenicio

Thanks for your findings @hbobenicio, although the problem with windows is completely different. Maybe you could help us all and give the bash script a review and send a PR with your findings? That would be much appreciated :)

diestrin avatar Feb 12 '20 20:02 diestrin

Sorry for messing the subject of this issue. gonna submit the PR soon! :+1:

hbobenicio avatar Feb 12 '20 20:02 hbobenicio