janoside / btc-rpc-explorer

Database-free, self-hosted Bitcoin explorer, via RPC to Bitcoin Core.
https://bitcoinexplorer.org
MIT License
1.5k stars 1.11k forks source link

Cannot read properties of null (reading 'accessKeyId') #443

Closed jsarenik closed 2 years ago

jsarenik commented 2 years ago

Describe the bug

When the recently-added BTCEXP_S3_... variables are not defined, the current master (87fe724a357e29fef0dd433b6d065a2ac55a3aab) ends with following error:

> btc-rpc-explorer@3.3.0 start
> node ./bin/www

  btcexp:app Searching for config files... +0ms
  btcexp:app Config file not found at /home/be/.config/btc-rpc-explorer.env, continuing... +6ms
  btcexp:app Config file not found at /etc/btc-rpc-explorer/.env, continuing... +0ms
  btcexp:app Config file not found at /home/be/src/btc-rpc-explorer/.env, continuing... +1ms
  btcexp:app No config files found. Using all defaults. +0ms
/home/be/src/btc-rpc-explorer/node_modules/@janoside/app-utils/src/s3Utils.js:13
debugLog(`Using AWS Access Key: ${AWS.config.credentials.accessKeyId}`);
                                                         ^

TypeError: Cannot read properties of null (reading 'accessKeyId')
    at Object.<anonymous> (/home/be/src/btc-rpc-explorer/node_modules/@janoside/app-utils/src/s3Utils.js:13:58)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/be/src/btc-rpc-explorer/node_modules/@janoside/app-utils/index.js:4:17)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/be/src/btc-rpc-explorer/app.js:99:18)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)

Environment (please complete the following information):

Configuration file content

No BTCEXP_S3 options set in the .env file. The Bitcoin Explorer works with following patch applied: https://github.com/jsarenik/btc-rpc-explorer/commit/768de3c182dd9ff275b16f730dcceea4b194e580

The '.env` file for ex.signet.bublina.eu.org:

BTCEXP_HOST=127.0.0.1
BTCEXP_PORT=3003
BTCEXP_BITCOIND_HOST=127.0.0.1
BTCEXP_BITCOIND_PORT=38332
BTCEXP_DEMO=true
BTCEXP_SLOW_DEVICE_MODE=true
BTCEXP_NO_RATES=true
BTCEXP_UI_HOME_PAGE_LATEST_BLOCKS_COUNT=6
BTCEXP_FILESYSTEM_CACHE_DIR=../../.cache/signet
BTCEXP_ADDRESS_API=electrum
BTCEXP_ELECTRUM_SERVERS=tls://signet-electrumx.wakiyamap.dev:50002
BTCEXP_ELECTRUM_TXINDEX=true
BTCEXP_UI_THEME=dark
BTCEXP_NO_INMEMORY_RPC_CACHE=true

To Reproduce

Steps to reproduce the behavior:

  1. Do not set any BTCEXP_S3 options in the env file.
  2. Start the Bitcoin Explorer with npm start.
  3. See error.
janoside commented 2 years ago

I believe d30b13a15fcbf578b2c070dbb928252a7f8d3421 should fix this. Please let me know if you're still having trouble after updating.

jsarenik commented 2 years ago

Yes. Looks great. Thanks!

pointbiz commented 2 years ago

I have this problem. Please re-open issue or explain how I resolve it.

pointbiz commented 2 years ago

My env file looks like this

BTCEXP_COIN=BTC BTCEXP_BITCOIND_URI=bitcoin://user:pass@127.0.0.1:8332?timeout=10000 BTCEXP_SLOW_DEVICE_MODE=false BTCEXP_ADDRESS_API=electrumx BTCEXP_ELECTRUMX_SERVERS=tcp://127.0.0.1:50001

pointbiz commented 2 years ago

Even if you do not create the s3 bucket the error is actually in the debugLog command above the createBucket.

This should be failing for others.

mat-h7 commented 2 years ago

+1 I am currently having the issue described by @pointbiz

pointbiz commented 2 years ago

@janoside @jsarenik could one of you re-open this issue? I got latest from master, npm install, npm start and I still get this error.

janoside commented 2 years ago

@pointbiz @mat-h7 Thanks for pushing on this. I believe the proper fix is included in ed4c974, which includes an update of the utility library used for S3 operations (make sure you do an npm install or npm up). If you update to the latest code, please let me know if you have any more problems here.

pointbiz commented 2 years ago

I tested and works for me now.

mat-h7 commented 2 years ago

I can also confirm that it is working for me now, thanks!