counter.js breaks with fatal error when connected by tendermind
paceto256 opened this issue · 4 comments
How to reproduce:
- checkout and build tendermint (current commit 1f8bb74bba0523aacdb76ed140339c48078c669b)
- checkout js-abci (current commit 7fbe690)
- start the counter.js example
node example/counter.js
- start tendermint
./build/tendermint start
Swith to the counte.js tab, It breaks with the error:
listening on port 26658
/home/paceto/proj/tendermint/js-abci/node_modules/protobufjs/src/reader.js:13
return RangeError("index out of range: " + reader.pos + " + " + (writeLength || 1) + " > " + reader.len);
^
RangeError: index out of range: 4 + 58 > 37
at indexOutOfRange (/home/paceto/proj/tendermint/js-abci/node_modules/protobufjs/src/reader.js:13:12)
at BufferReader.skip (/home/paceto/proj/tendermint/js-abci/node_modules/protobufjs/src/reader.js:334:19)
at BufferReader.Reader.skipType (/home/paceto/proj/tendermint/js-abci/node_modules/protobufjs/src/reader.js:360:18)
at Function.decode (/home/paceto/proj/tendermint/js-abci/node_modules/abci/types.js:841:28)
at Function.decode (/home/paceto/proj/tendermint/js-abci/node_modules/abci/types.js:241:61)
at Connection.maybeReadNextMessage (/home/paceto/proj/tendermint/js-abci/node_modules/abci/src/connection.js:55:27)
at Connection.onData (/home/paceto/proj/tendermint/js-abci/node_modules/abci/src/connection.js:32:10)
at Socket.emit (node:events:365:28)
at addChunk (node:internal/streams/readable:314:12)
at readableAddChunk (node:internal/streams/readable:289:9)
tendermint should be call with abci parameter:
tendermint start --abci grpc
@paceto256 , how did you manage to run the exmaple? I'm trying to start it from the same exact commit, and I'm getting:
➜ js-abci git:(master) ✗ node example/counter.js
internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module 'abci'
Require stack:
- /Users/ppe/Projects/tdmint-app/js-abci/example/counter.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/Users/ppe/Projects/tdmint-app/js-abci/example/counter.js:1:24)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/ppe/Projects/tdmint-app/js-abci/example/counter.js' ]
I've managed to run the example by changing the
let createABCIServer = require('abci')
to
let createABCIServer = require('../src/server')
Starting the tendermint with tendermint start --abci grpc
ends with
2021-11-25T20:03:38+01:00 INFO starting service impl=multiAppConn module=proxy service=multiAppConn
2021-11-25T20:03:38+01:00 INFO starting service connection=query impl=grpcClient module=abci-client service=grpcClient
2021-11-25T20:03:38+01:00 INFO Dialed server. Waiting for echo. addr=tcp://127.0.0.1:26658 connection=query module=abci-client
- no block are being produced.
If someone is looking for a working example of counter.js, then tendermint 0.32.12 worked for me - without introducing any changes, all the messages are correctly processed.
Changing counter state via curl or by RpcClient working as well.
Hope it helps save some time for others.