Problem 4a: `Autobase.append` "Cannot read property 'length' of undefined"
r-token opened this issue · 0 comments
r-token commented
When calling Autobase.append
, I receive an error that says "TypeError: Cannot read property 'length' of undefined".
Here's the full stack trace:
/path-to-project/node_modules/autobase/index.js:441
const head = await this._getInputNode(input, input.length - 1)
^
TypeError: Cannot read property 'length' of undefined
at Autobase.append (/path-to-project/node_modules/autobase/index.js:441:56)
at async file:///path-to-project/autobase-practice.js:17:1
Here's my code:
import Corestore from 'corestore'
import Autobase from 'autobase'
import ram from 'random-access-memory'
// Create two chat users, each with their own Hypercores.
// Here since we'll be rerunning the same code a lot, we'll use the ram storage
const store = new Corestore(ram)
const userA = store.get({ name: 'userA' })
const userB = store.get({ name: 'userB' })
// Make an Autobase with those two users as inputs.
const baseA = new Autobase([userA, userB], { input: userA })
const baseB = new Autobase([userA, userB], { input: userB })
await baseA.append('A0: hello!')
await baseB.append('B0: hi! good to hear from you')
await baseA.append('A1: likewise. fun exercise huh?')
await baseB.append('B1: yep. great time.')
// Let's print all messages in causal order
for await (const node of baseA.createCausalStream()) {
console.log(node.value.toString())
}
And here's my package.json
:
{
"name": "autobase-practice",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"autobase": "^1.0.0-alpha.8",
"chalk": "^5.0.0",
"corestore": "^6.0.1-alpha.9",
"random-access-memory": "^4.0.0"
}
}