dtube / avalon

Blockchain for social distribution

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Cannot read property 'suffle'" after restarting node

kekkyojin opened this issue · comments

From tiem to time I stop my leader node and the Mongo server. After a few hours I restart them and I am consistently getting this TypeError which causes the start.sh to stop. When I try again, it just works.

Here I paste the log:

mac-mini:~ javi$ mongod --config /usr/local/etc/mongod.conf &
[1] 828
mac-mini:~ javi$ cd avalon
mac-mini:avalon javi$ ./scripts/start.sh
20:58:11.157 [INFO] Logger initialized
20:58:24.739 [INFO] Correctly using NodeJS v10.15.0
20:58:24.814 [INFO] Connected to mongodb://localhost:27017/avalon
20:58:25.003 [INFO] #1977747 is the latest block in our db
20:58:25.150 [INFO] Listening websocket p2p port on: 6001
20:58:25.157 [INFO] Listening http on port: 3001
20:58:25.159 [INFO] Generating schedule... NRNG: 11896451
20:58:25.383 [DEBUG] Handshaking new peer ws://35.203.37.221:6001
/Users/javi/avalon/src/chain.js:383
if (chain.schedule.shuffle[(newBlock._id-1)%config.leaders].name === newBlock.miner)
^

TypeError: Cannot read property 'shuffle' of null
at Object.isValidNewBlock (/Users/javi/avalon/src/chain.js:383:28)
at Object.validateAndAddBlock (/Users/javi/avalon/src/chain.js:131:15)
at Object.addRecursive (/Users/javi/avalon/src/p2p.js:266:15)
at WebSocket.ws.on (/Users/javi/avalon/src/p2p.js:143:25)
at WebSocket.emit (events.js:182:13)
at Receiver.receiverOnMessage (/Users/javi/avalon/node_modules/ws/lib/websocket.js:800:20)
at Receiver.emit (events.js:182:13)
at Receiver.dataMessage (/Users/javi/avalon/node_modules/ws/lib/receiver.js:422:14)
at perMessageDeflate.decompress (/Users/javi/avalon/node_modules/ws/lib/receiver.js:379:23)
at _decompress (/Users/javi/avalon/node_modules/ws/lib/permessage-deflate.js:298:9)
at _inflate.flush (/Users/javi/avalon/node_modules/ws/lib/permessage-deflate.js:377:7)
at afterWrite (_stream_writable.js:480:3)
at onwrite (_stream_writable.js:471:7)
at InflateRaw.afterTransform (_stream_transform.js:94:3)
at Zlib.processCallback (zlib.js:619:8)
mac-mini:avalon javi$ ./scripts/start.sh
20:58:32.038 [INFO] Logger initialized
20:58:32.824 [INFO] Correctly using NodeJS v10.15.0
20:58:32.869 [INFO] Connected to mongodb://localhost:27017/avalon
20:58:32.890 [INFO] #1977747 is the latest block in our db
20:58:32.952 [INFO] Listening websocket p2p port on: 6001
20:58:32.959 [INFO] Listening http on port: 3001
20:58:32.961 [INFO] Generating schedule... NRNG: 11896451
20:58:33.089 [WARN] peer connection failed ws://185.178.193.56
20:58:33.122 [DEBUG] Handshaking new peer ws://139.59.209.189:6001
20:58:33.135 [DEBUG] Handshaking new peer ws://34.65.181.103:6001

This bug is out I believe. Not sure what caused it back then but it's not happening anymore