ssbc / ssb-server

The gossip and replication server for Secure Scuttlebutt - a distributed social network
1.68k stars 164 forks source link

Server crashing with "Error: can only encode arrays" #737

Closed timjrobinson closed 3 years ago

timjrobinson commented 3 years ago

us-east.ssbpeer.net started crashing with this error in the last day. It were down for a few weeks because of some database flaw, and after resetting the database and reconnecting to the network it's started crashing with this. I'm running as root user installed via npm install -g ssb-server@latest and running with ssb-server start

Versions:

Debian GNU/Linux 9.13
ssb-server@16.0.1
node@10.22.1
npm@6.14.6

Stack Trace:

Error: can only encode arrays
    at encode (/root/.nvm/versions/node/v10.22.1/lib/node_modules/ssb-server/node_modules/charwise/codec/object.js:27:44)
    at encodeItem (/root/.nvm/versions/node/v10.22.1/lib/node_modules/ssb-server/node_modules/charwise/codec/object.js:41:20)
    at encode (/root/.nvm/versions/node/v10.22.1/lib/node_modules/ssb-server/node_modules/charwise/codec/object.js:33:24)
    at encodeItem (/root/.nvm/versions/node/v10.22.1/lib/node_modules/ssb-server/node_modules/charwise/codec/object.js:41:20)
    at Object.encode (/root/.nvm/versions/node/v10.22.1/lib/node_modules/ssb-server/node_modules/charwise/codec/object.js:33:24)
    at Object.exports.encode (/root/.nvm/versions/node/v10.22.1/lib/node_modules/ssb-server/node_modules/charwise/index.js:39:28)
    at Codec.encodeKey (/root/.nvm/versions/node/v10.22.1/lib/node_modules/ssb-server/node_modules/level-codec/index.js:32:45)
    at /root/.nvm/versions/node/v10.22.1/lib/node_modules/ssb-server/node_modules/level-codec/index.js:53:17
    at Array.map (<anonymous>)
    at Codec.encodeBatch (/root/.nvm/versions/node/v10.22.1/lib/node_modules/ssb-server/node_modules/level-codec/index.js:50:14)
timjrobinson commented 3 years ago

The content of the array variable that is causing this error is:

{ dev: 1991025716,
  mode: 33206,
  nlink: 1,
  uid: 0,
  gid: 0,
  rdev: 0,
  blksize: 4096,
  ino: 5066549581027855,
  size: 14118,
  blocks: 32,
  atimeMs: 1601999455655.479,
  mtimeMs: 1599578648743.5425,
  ctimeMs: 1599584494100.568,
  birthtimeMs: 1599579927920.083,
  atime: '2020-10-06T15:50:55.655Z',
  mtime: '2020-09-08T15:24:08.744Z',
  ctime: '2020-09-08T17:01:34.101Z',
  birthtime: '2020-09-08T15:45:27.920Z' }
arj03 commented 3 years ago

You need to update ssb-links @timjrobinson

clehner commented 3 years ago

Yes, this looks like https://github.com/ssbc/ssb-links/pull/13. I guess we have to update the version in ssb-server's package.json. I'll make a PR for that.