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

TypeError: Cannot read property 'length' of undefined #118

Closed
sp00lin9 opened this issue Dec 6, 2017 · 20 comments
Closed

TypeError: Cannot read property 'length' of undefined #118

sp00lin9 opened this issue Dec 6, 2017 · 20 comments

Comments

@sp00lin9
Copy link

sp00lin9 commented Dec 6, 2017

Hello All! Thank you for the great work & support! Wondering if anyone has ran into this issue before -

/explorer/lib/explorer.js:344
module.exports.syncLoop(tx.vout.length, function (loop) {
^
TypeError: Cannot read property 'length' of undefined
at /root/explorer/lib/explorer.js:344:42
at Request._callback (/root/explorer/lib/explorer.js:114:14)
at Request.self.callback (/root/explorer/node_modules/request/request.js:187:22)
at emitTwo (events.js:125:13)
at Request.emit (events.js:213:7)
at Request. (/root/explorer/node_modules/request/request.js:1044:10)
at emitOne (events.js:115:13)
at Request.emit (events.js:210:7)
at IncomingMessage. (/root/explorer/node_modules/request/request.js:965:12)
at emitNone (events.js:110:20)
at IncomingMessage.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1059:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

Whatever I try, I cant get it to sync past a block 171620. Neither index update, index reindex & index check will get past that block 171620. If anyone can point me in the right direction I'd appreciate it.

Thank you!

@sp00lin9
Copy link
Author

sp00lin9 commented Dec 7, 2017

I can provide the output of the getblockbynumber for 171620 & 171621 if needed. Please let me know.

Thanks.

@sp00lin9
Copy link
Author

sp00lin9 commented Dec 7, 2017

Just found this in my explorer output as I run the npm start before attempting the update -

{ Error: No information available about transaction
at /root/explorer/node_modules/bitcoin-node-api/node_modules/bitcoin/lib/jsonrpc.js:99:19
at Array.forEach ()
at IncomingMessage. (/root/explorer/node_modules/bitcoin-node-api/node_modules/bitcoin/lib/jsonrpc.js:96:15)
at emitNone (events.js:110:20)
at IncomingMessage.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1059:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9) code: -5 }

@sp00lin9
Copy link
Author

sp00lin9 commented Dec 8, 2017

It will oddly enough let me manually add blocks to the block explorer using the api, but wont pick them up on its own after block 171620.

Anyone have even the slightest clue?

@erfan007p
Copy link

try to reindex your daemon and run index reindex or index check

@sp00lin9
Copy link
Author

sp00lin9 commented Dec 8, 2017

I've tried deleting & redownloading the block chain for the daemon, then running index reindex & it still gives me

/explorer/lib/explorer.js:344
module.exports.syncLoop(tx.vout.length, function (loop) {
^
TypeError: Cannot read property 'length' of undefined
at /root/explorer/lib/explorer.js:344:42
at Request._callback (/root/explorer/lib/explorer.js:114:14)
at Request.self.callback (/root/explorer/node_modules/request/request.js:187:22)
at emitTwo (events.js:125:13)
at Request.emit (events.js:213:7)
at Request. (/root/explorer/node_modules/request/request.js:1044:10)
at emitOne (events.js:115:13)
at Request.emit (events.js:210:7)
at IncomingMessage. (/root/explorer/node_modules/request/request.js:965:12)
at emitNone (events.js:110:20)
at IncomingMessage.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1059:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

index check also gives me this error ^^^

I havent tried starting the daemon with the -reindex flag, then running index reindex, so I'll try that, wouldnt hurt at this point lol

@sp00lin9
Copy link
Author

sp00lin9 commented Dec 11, 2017

Well, I've tried everything above with no luck. Not sure what else to do...

Interesting to note that if I search blocks with the api, they'll get added to the database & will display in the block explorer, but it wont pick up the blocks on it own with index update, reindex and check.

@Igor-san
Copy link

try in file explorer.js in function
syncLoop: function (iterations, process, exit) {
....
if (index% 100 === 0) {// clear stack

change value 100 to 30 (or other smaller)

@sp00lin9
Copy link
Author

sp00lin9 commented Dec 11, 2017

Thanks for the suggestion, I tried updating with no luck but I'm reindexing with the changes now & my fingers crossed! I'll report back with what I find.

@sp00lin9
Copy link
Author

I tried to update first then reindex with the same result /:

@sp00lin9
Copy link
Author

sp00lin9 commented Dec 13, 2017

Looks like block 171621, the one it wont sync past, has a non-standard transaction, but this commit looks like it should've taken care of this issue?

2c0cf36

@rupaya-project
Copy link

did anyone figure out what the issue is ? is there any fix ?

@VishalDalve
Copy link

VishalDalve commented Feb 28, 2018

Same issue. Anyone sloved??

TypeError: Cannot read property 'length' of undefined
at C:\Users\Vishal\Downloads\explorer\lib\database.js:642:37
at Request._callback (C:\Users\Vishal\Downloads\explorer\lib\explorer.js:107:14)
at Request.self.callback (C:\Users\Vishal\Downloads\explorer\node_modules\request\request.js:187:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request. (C:\Users\Vishal\Downloads\explorer\node_modules\request\request.js:1044:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage. (C:\Users\Vishal\Downloads\explorer\node_modules\request\request.js:965:12)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1056:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

@blakey12345
Copy link

  module.exports.get_rawtransaction(input.txid, function(tx){
    if (tx) {
      if (tx.vout) { //Added
        console.log('tx.vout: %o', tx.vout); //Added
        module.exports.syncLoop(tx.vout.length, function (loop) {
          var i = loop.iteration();
          if (tx.vout[i].n == input.vout) {
            //module.exports.convert_to_satoshi(parseFloat(tx.vout[i].value), function(amount_sat){
            if (tx.vout[i].scriptPubKey.addresses) {
              addresses.push({hash: tx.vout[i].scriptPubKey.addresses[0], amount:tx.vout[i].value});
            }
              loop.break(true);
              loop.next();
            //});
          } else {
            loop.next();
          }
        }, function(){
          return cb(addresses);
        });
      } else {
        return cb();
      }
    } else {//Added
      return cb();//Added
    }//Added
  });

@voxcon
Copy link

voxcon commented Mar 22, 2018

@blakey12345 where do i have to implement your code in order to be able to execute the index command correctly?

Edit: figured it out. Thanks anyways :)

@lukepighetti
Copy link

lukepighetti commented Mar 25, 2018

Where does this go? Is there an official pull request?

@lukepighetti
Copy link

lukepighetti commented Mar 25, 2018

blakey's snippet references /lib/explorer.js Line 341

@leegod
Copy link

leegod commented Mar 28, 2018

I revised /lib/explorer.js Line 341 with above code, but still get length error.

@pivxslimjim
Copy link

As do i @leegod
You fix it?

@olegmitrakhovich
Copy link

I used the code provided by blakey, but still getting the same issue also (Cannot read property 'length' of undefined)

@TheHolyRoger
Copy link
Collaborator

Duplicate of #56

@TheHolyRoger TheHolyRoger marked this as a duplicate of #56 Dec 25, 2019
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