raiden-network / light-client

The Raiden Light Client
https://raiden.network/
MIT License
33 stars 31 forks source link

InternalServerError: Cannot read properties of undefined (reading 'connection') #3169

Closed karlb closed 2 years ago

karlb commented 2 years ago

Following https://www.youtube.com/watch?v=zOXFRRzeSf4, I get to the following error of the light client CLI in step5:

InternalServerError: Cannot read properties of undefined (reading 'connection')
    at Object.internalErrorHandler (/home/karl/.config/yarn/global/node_modules/@raiden_network/raiden-cli/build/app.js:20:36)
    at Layer.handle_error (/home/karl/.config/yarn/global/node_modules/express/lib/router/layer.js:71:5)
    at trim_prefix (/home/karl/.config/yarn/global/node_modules/express/lib/router/index.js:326:13)
    at /home/karl/.config/yarn/global/node_modules/express/lib/router/index.js:286:9
    at Function.process_params (/home/karl/.config/yarn/global/node_modules/express/lib/router/index.js:346:12)
    at next (/home/karl/.config/yarn/global/node_modules/express/lib/router/index.js:280:10)
    at Layer.handle_error (/home/karl/.config/yarn/global/node_modules/express/lib/router/layer.js:67:12)
    at trim_prefix (/home/karl/.config/yarn/global/node_modules/express/lib/router/index.js:326:13)
    at /home/karl/.config/yarn/global/node_modules/express/lib/router/index.js:286:9
    at Function.process_params (/home/karl/.config/yarn/global/node_modules/express/lib/router/index.js:346:12)

The error in the WebUI is

JSON RPC connection error!
A connection with the Web3 provider could not be established. Please try again. 

I'm using version 3.1.2 with the command line raiden --datadir ./raiden.storage --eth-rpc-endpoint https://rinkeby.arbitrum.io/rpc raiden --keystore-path ~/.ethereum/keystore/ --web-ui.

andrevmatos commented 2 years ago

@karl this error is very weird, it would only happen if somehow you ended up with SDK (raiden-ts) version < 3.1, as it seems to be failing while accessing the provider exposed by the SDK. Can you, please, check the SDK version in ~/.local/share/yarn/global/node_modules/raiden-ts/package.json and if you can see the get provider() line in ~/.local/share/yarn/global/node_modules/raiden-ts/dist:cjs/raiden.js please?

karlb commented 2 years ago

Hmm, there seems to be something wrong with my install, although I did yarn global add @raiden_network/raiden-cli as instructed and I don't remember seeing any errors. I don't have the files at ~/.local/share/yarn, but at ~/.config/yarn. I assume this is a distribution dependent difference and not the problem.

$ grep '"version"' ~/.config/yarn/global/node_modules/raiden-ts/package.json 
  "version": "3.0.0",
$ grep 'get provider()' ~/.config/yarn/global/node_modules/raiden-ts/dist:cjs/raiden.js
<no output>
$ which raiden
/home/karl/.yarn/bin/raiden
$ raiden -V
3.1.2

Removing and reinstalling does not change anything.

$ rm -fr ~/.config/yarn/global/node_modules/raiden-ts
$ yarn global add @raiden_network/raiden-cli
yarn global v1.22.15
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "@raiden_network/raiden-cli > raiden-ts > eslint-import-resolver-typescript@2.7.1" has unmet peer dependency "eslint@*".
warning "@raiden_network/raiden-cli > raiden-ts > eslint-import-resolver-typescript@2.7.1" has unmet peer dependency "eslint-plugin-import@*".
warning "wrtc@0.4.7" is missing a bundled dependency "node-pre-gyp". This should be reported to the package maintainer.
[4/4] Building fresh packages...
success Installed "@raiden_network/raiden-cli@3.1.2" with binaries:
      - raiden
$ grep '"version"' ~/.config/yarn/global/node_modules/raiden-ts/package.json 
  "version": "3.0.0",
andrevmatos commented 2 years ago

This may be caused by yarn cache or something like that; could you please test nuking the whole ~/.config/yarn and ~/.cache/yarn, and then reinstalling, to see if you get the correct version? It did work here on a pristine container.

karlb commented 2 years ago

Yes, that helps. I still don't understand why I got the new version when running raiden -V but the old behavior.

andrevmatos commented 2 years ago

The reason is that you got the most recent raiden-cli (v3.1.2), but you had its dependency, the SDK, already satisfied (^3) in the cache or in the global path, which made yarn reuse it instead of downloading the most recent version for the SDK. So, raiden -V showed the correct version for the CLI, but outdated SDK. We may end up tightening the requirement range for the SDK to avoid this sort fo problem in the future, but this won't happen with a new user on a new environment, so it should be good enough the way it is now. Thanks for looking this up.