EOSIO / demux-js

💫 Deterministic event-sourced state and side effect handling for blockchain applications
MIT License
305 stars 71 forks source link

TypeError when running eos-transfers example #102

Open angelol opened 5 years ago

angelol commented 5 years ago

When running the unmodified eos-transfers example, after a while I get the following error:

{"name":"demux","hostname":"Ubuntu-1804-bionic-64-minimal","pid":30211,"level":30,"msg":"Rolling back 1 blocks to block 7986487...","time":"2019-01-10T05:07:43.811Z","v":0}
(node:30211) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'indexState' of undefined
    at ObjectActionHandler.loadIndexState (/home/demo/demux-js/examples/eos-transfers/ObjectActionHandler.js:56:18)
    at ObjectActionHandler.<anonymous> (/home/demo/demux-js/examples/eos-transfers/node_modules/demux/dist/AbstractActionHandler.js:165:79)
    at Generator.next (<anonymous>)
    at /home/demo/demux-js/examples/eos-transfers/node_modules/demux/dist/AbstractActionHandler.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/home/demo/demux-js/examples/eos-transfers/node_modules/demux/dist/AbstractActionHandler.js:3:12)
    at ObjectActionHandler.refreshIndexState (/home/demo/demux-js/examples/eos-transfers/node_modules/demux/dist/AbstractActionHandler.js:164:16)
    at ObjectActionHandler.<anonymous> (/home/demo/demux-js/examples/eos-transfers/node_modules/demux/dist/AbstractActionHandler.js:50:28)
    at Generator.next (<anonymous>)
    at fulfilled (/home/demo/demux-js/examples/eos-transfers/node_modules/demux/dist/AbstractActionHandler.js:4:58)
(node:30211) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:30211) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I suspect it has something to do with fork handling because it usually comes immediately after a fork has been handled, but not always. Sometimes it handles a dozen forks fine and then suddenly, the error pops up.

The Jungle testnet seems to have conditions that provoke this error more often than then mainnet.

angelol commented 5 years ago

Addendum: The process just freezes after this error. The only way to resolve it is to restart the process.

jeffreyssmith2nd commented 5 years ago

Thanks for following up, sorry this got dropped. I'll try to take a look at this when I have a few minutes.

jeffreyssmith2nd commented 5 years ago

I've been running for over 6 hours and haven't run into this issue. Do you happen to know of a block I could start at that might trigger this condition?

One thing to note, I have seen long periods of inactivity where if I hadn't added extra logging I would have assumed it was frozen.

flux627 commented 5 years ago

It seems the only place where state could be set to undefined is here. That would mean that there is no block history at the given index, which means there's probably something wrong with the toDelete assignment right above. I'll get to this eventually, but since this is a problem with just the example, it is low priority. If anyone else wants to tackle it and make a PR it would be greatly appreciated!