keppel / lotion

✨ Smooth, easy blockchain apps ✨
https://lotionjs.com
974 stars 133 forks source link

UnhandledPromiseRejectionWarning: Error: invalid wire type 7 at offset 88 #196

Closed ilovelili closed 4 years ago

ilovelili commented 4 years ago

I got UnhandledPromiseRejectionWarning: Error: invalid wire type 7 at offset 88 at BufferReader.Reader.skipType when I try to run the example code the official website provided. The application appears to keep running despite the errors/warnings, but the GCI never shows up.

let lotion = require('lotion');

let app = lotion({
    initialState: {
        count: 0
    }
});

function transactionHandler(state, transaction) {
    if (state.count === transaction.nonce) {
        state.count++;
    }
}

app.use(transactionHandler);
app.start().then(appInfo => console.log(appInfo.GCI));
node app.js
f45913bb5b7be4d2723cffca5ad99e87bb72a2adfd652bf0e25d1bff81caed21
(node:17887) UnhandledPromiseRejectionWarning: Error: invalid wire type 7 at offset 88
    at BufferReader.Reader.skipType (/home/min/Projects/lx/src/github.com/ilovelili/counter/node_modules/protobufjs/src/reader.js:373:19)
    at Function.decode (/home/min/Projects/lx/src/github.com/ilovelili/counter/node_modules/abci/types.js:8722:28)
    at Function.decode (/home/min/Projects/lx/src/github.com/ilovelili/counter/node_modules/abci/types.js:8214:58)
    at Function.decode (/home/min/Projects/lx/src/github.com/ilovelili/counter/node_modules/abci/types.js:2114:56)
    at Function.decode (/home/min/Projects/lx/src/github.com/ilovelili/counter/node_modules/abci/types.js:256:71)
    at Connection.maybeReadNextMessage (/home/min/Projects/lx/src/github.com/ilovelili/counter/node_modules/abci/src/connection.js:55:27)
    at Connection.onData (/home/min/Projects/lx/src/github.com/ilovelili/counter/node_modules/abci/src/connection.js:32:10)
    at Socket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
(node:17887) 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: 5)
(node:17887) [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.
$ lotion state 3b85ef9ce11b7ac5059537baf2d02853119c41d26112052e499275d0945fbf51
#### nothing shows up

My node version is 10.16.1. I am running it on Ubuntu 18.04

davvidess commented 4 years ago

It is related to nomic-io/tendermint-node#15. It happens because tendermint-node was updated to newer version of tendermint core, but there were probably some api changes so it broke.

As a quick fix you can use my forked version of tendermint-node davvidess/tendermint-node@8edaed7df66790eba1a1b98acf4c30250a14180b where I reverted the update.

But tendermint-node is a sub-dependency of lotion, so you either have to manually set the version in your package-lock.json

or if you use yarn you can declare a sub-dependency by adding this to your package.json

"resolutions": {
    "lotion/tendermint-node": "https://github.com/davvidess/tendermint-node/tarball/8edaed7df66790eba1a1b98acf4c30250a14180b"
  }
ilovelili commented 4 years ago

Thank you very much @davvidess !