Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Error When Trying To View Individual Blocks #45

Closed
apbendi opened this issue Aug 9, 2018 · 13 comments
Closed

Getting Error When Trying To View Individual Blocks #45

apbendi opened this issue Aug 9, 2018 · 13 comments

Comments

@apbendi
Copy link

apbendi commented Aug 9, 2018

visiting an individual block url, such as http://127.0.0.1:3002/block-height/535967, results in the following error:

/Users/redacted/Development/btc-rpc-explorer/views/includes/transaction-io-details.pug:10 8| each txInput, txInputIndex in txInputs 9| if (txInput) > 10| - var vout = txInput.vout[tx.vin[txInputIndex].vout]; 11| if (vout.value) 12| - totalInputValue = totalInputValue.plus(new Decimal(vout.value)); 13| Cannot read property 'undefined' of undefined

TypeError: /Users/redacted/Development/btc-rpc-explorer/views/includes/transaction-io-details.pug:10
    8| each txInput, txInputIndex in txInputs
    9| 	if (txInput)
  > 10| 		- var vout = txInput.vout[tx.vin[txInputIndex].vout];
    11| 		if (vout.value)
    12| 			- totalInputValue = totalInputValue.plus(new Decimal(vout.value));
    13| 

Cannot read property 'undefined' of undefined
    at eval (eval at wrap (/Users/redacted/Development/btc-rpc-explorer/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:1145:24)
    at eval (eval at wrap (/Users/redacted/Development/btc-rpc-explorer/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:1170:4)
    at eval (eval at wrap (/Users/redacted/Development/btc-rpc-explorer/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:2483:4)
    at template (eval at wrap (/Users/redacted/Development/btc-rpc-explorer/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:2900:72)
    at Object.exports.renderFile (/Users/redacted/Development/btc-rpc-explorer/node_modules/pug/lib/index.js:427:38)
    at Object.exports.renderFile (/Users/redacted/Development/btc-rpc-explorer/node_modules/pug/lib/index.js:417:21)
    at exports.__express (/Users/redacted/Development/btc-rpc-explorer/node_modules/pug/lib/index.js:464:11)
    at View.app.engine (/Users/redacted/Development/btc-rpc-explorer/app.js:39:23)
    at View.render (/Users/redacted/Development/btc-rpc-explorer/node_modules/express/lib/view.js:135:8)
    at tryRender (/Users/redacted/Development/btc-rpc-explorer/node_modules/express/lib/application.js:640:10)
    at Function.render (/Users/redacted/Development/btc-rpc-explorer/node_modules/express/lib/application.js:592:3)
    at ServerResponse.render (/Users/redacted/Development/btc-rpc-explorer/node_modules/express/lib/response.js:1008:7)
    at /Users/redacted/Development/btc-rpc-explorer/routes/baseActionsRouter.js:405:8
    at process._tickCallback (internal/process/next_tick.js:109:7)

As a sanity check, the RPC calls to my node for getblockhash and getblock work fine via curl. Running macOS Sierra. Any thoughts?

Thanks for a great tool!

@janoside
Copy link
Owner

janoside commented Aug 9, 2018

@apbendi Can you check what your latest commit is? Trying to reproduce on the demo site I'm not seeing the error for that particular block: https://btc.chaintools.io/block-height/535967

Another question: do you have pruning active on your node?

Glad you're enjoying the tool!

@apbendi
Copy link
Author

apbendi commented Aug 9, 2018

Thanks for the fast reply! I cloned master just a few minutes before reporting the issue. The issue seems to occur for all blocks-- I tried with a series of recent blocks, as well as the genesis block, and received the same error. My node is not pruning-- I'm in sync with the full chain and can run curl on any block to get the block data. The rest of the block explorer seems to work fine!

Just in case it matters, my node is not the same machine as the one running the explorer. The node is running Linux and is on the same LAN. The local IP of my Mac (where the explorer is running) is whitelisted in my node's config, and, as mentioned, can make RPC calls via curl w/o issue.

Let me know if theres anything I can do to help debug the issue on my end. Thanks!

@janoside
Copy link
Owner

Thanks for the additional info. Given the error you're seeing, your setup (linux node, mac explorer) shouldn't be the cause.

Another question: What version is your node? I'm currently running "/Satoshi:0.16.0/" both locally and on the demo server (haven't gotten around to upgrading to 0.16.2 yet)

I just pushed some code that could help in debugging. If you update to at least commit a53e92f and navigate to a block-details page I'm hoping that some of the code changes at least provide some armor against the specific error you're seeing and may give some additional debugging insight.

janoside added a commit that referenced this issue Aug 10, 2018
janoside added a commit that referenced this issue Aug 10, 2018
@janoside
Copy link
Owner

Hmmm, this has me scratching my head a bit, mostly because I can't think of what could be different between your env and mine. I see some brittle, error-prone code related to the errors you're seeing, but again, I can't tell why you're seeing errors and I'm not. I'd like to improve the error-prone code, but hopefully get you up and running before that.

I have a couple more commits you can try out and let me know. I appreciate your report and your help resolving.

@apbendi
Copy link
Author

apbendi commented Aug 10, 2018

I'll try your commits-- but it just occurred to me I'm on a rather old version of node v7.9.0. Any chance this could be part of the problem?

@apbendi
Copy link
Author

apbendi commented Aug 10, 2018

So this is very weird! I updated to node 10.x and also pulled down your latest commits. I'm still seeing errors, but now it's about 50% of the time. The rest seem to work.

/Users/redacted/Development/btc-rpc-explorer/views/includes/transaction-io-details.pug:4 2| - var fontawesomeOutputName = "sign-out-alt"; 3| > 4| - var totalIOValues = utils.getTxTotalInputOutputValues(tx, txInputs, blockHeight); 5| 6| div(class="row") 7| div(class="col-md-6") Cannot read property 'length' of undefined

TypeError: /Users/redacted/Development/btc-rpc-explorer/views/includes/transaction-io-details.pug:4
    2| - var fontawesomeOutputName = "sign-out-alt";
    3| 
  > 4| - var totalIOValues = utils.getTxTotalInputOutputValues(tx, txInputs, blockHeight);
    5| 
    6| div(class="row")
    7| 	div(class="col-md-6")

Cannot read property 'length' of undefined
    at Object.getTxTotalInputOutputValues (/Users/redacted/Development/btc-rpc-explorer/app/utils.js:220:29)
    at eval (eval at wrap (/Users/redacted/Development/btc-rpc-explorer/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:1129:27)
    at eval (eval at wrap (/Users/redacted/Development/btc-rpc-explorer/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:2531:4)
    at template (eval at wrap (/Users/redacted/Development/btc-rpc-explorer/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:2948:72)
    at Object.exports.renderFile (/Users/redacted/Development/btc-rpc-explorer/node_modules/pug/lib/index.js:427:38)
    at Object.exports.renderFile (/Users/redacted/Development/btc-rpc-explorer/node_modules/pug/lib/index.js:417:21)
    at exports.__express (/Users/redacted/Development/btc-rpc-explorer/node_modules/pug/lib/index.js:464:11)
    at View.app.engine (/Users/redacted/Development/btc-rpc-explorer/app.js:39:23)
    at View.render (/Users/redacted/Development/btc-rpc-explorer/node_modules/express/lib/view.js:135:8)
    at tryRender (/Users/redacted/Development/btc-rpc-explorer/node_modules/express/lib/application.js:640:10)
    at Function.render (/Users/redacted/Development/btc-rpc-explorer/node_modules/express/lib/application.js:592:3)
    at ServerResponse.render (/Users/redacted/Development/btc-rpc-explorer/node_modules/express/lib/response.js:1008:7)
    at /Users/redacted/Development/btc-rpc-explorer/routes/baseActionsRouter.js:439:7
    at process._tickCallback (internal/process/next_tick.js:68:7)

janoside added a commit that referenced this issue Aug 10, 2018
@janoside
Copy link
Owner

Interesting. So do you mean that you can refresh the same page and it will work 50% of the time, or that 50% of blocks that you view result in errors? I'm hoping for the latter option, in which case I have a handle on something concrete. There's another commit you can try which I'm hoping could get you most of the way there while I address the remaining issue.

janoside added a commit that referenced this issue Aug 10, 2018
@janoside
Copy link
Owner

Eh...I'm doubting the idea I had a little bit ago. But still let me know about the latest commits.

@apbendi
Copy link
Author

apbendi commented Aug 13, 2018

I should have some time to play with this again tomorrow and I'll let you know. Thanks!

@janoside
Copy link
Owner

@apbendi Any update on this?

@apbendi
Copy link
Author

apbendi commented Sep 10, 2018

Hey @janoside, gonna look into it this afternoon. Thanks for your patience!

@apbendi
Copy link
Author

apbendi commented Sep 10, 2018

So, embarrassingly, I had a typo in my bitcoin.conf file such that txindex was not turned on. Currently reindexing my blocks. The reason it worked sometime is that transactions that were still/recently in the mempool would return. When blocks got stale, it would fail.

One useful thing here, for other dummies like me, might be to look for the error message returned by the node when asking for a transaction that is not indexed, and then display something helpful in the UI. Anyway, closing this issue out.

By the way, I wrote up a guide for running a full node as a developer, and included running your explorer as part of it. Thought you might enjoy: https://www.buildblockchain.tech/blog/btc-node-developers-guide

Thanks for an awesome tool! Cheers!

@janoside
Copy link
Owner

Ah-ha! Thanks for the update. I'm glad we got to the bottom of this. I like your idea concerning the error-message detail and created #50 to track it. Thanks so much for your full-node-with-explorer guide...that's awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants