Orbit-db: Error when using go-ipfs daemon with ipfs-http-client

Created on 28 Jan 2019  路  7Comments  路  Source: orbitdb/orbit-db

I have my daemon running with the command: ipfs daemon --enable-pubsub-experiment.

When I try to create a database with js-ipfs-http-client, I get an error. This is the code:

const ipfsClient = require('ipfs-http-client');
const OrbitDB = require('orbit-db');

const ipfs = ipfsClient({host: 'localhost', port: '5001', protocol: 'http'});         

const orbitdb = new OrbitDB(ipfs);

const testDB = async () => {
    try {
        const db = await orbitdb.keyvalue('first-database');
        const entry = await db.set('name', 'jonas');
        console.log(entry);
        const value = await db.get('name');
   } catch (err) {
        console.log(err);
    }
    await orbitdb.disconnect();
}

testDB();

And this is the error:

ACCESS ERROR: TypeError: Cannot read property 'toString' of undefined
    at IPFSAccessController.save (/home/arched/Projects/test/node_modules/orbit-db/src/ipfs-access-controller.js:31:36)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at validateString (internal/validators.js:125:11)
    at Object.join (path.js:1147:7)
    at createDBManifest (/home/arched/Projects/test/node_modules/orbit-db/src/db-manifest.js:8:28)
    at OrbitDB.create (/home/arched/Projects/test/node_modules/orbit-db/src/OrbitDB.js:250:32)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)

I have no problems when just using the IPFS module to create a js-ipfs node, it's only when I try to use the API of a running node that I get an error.

Most helpful comment

I'll keep this issue open so we can try to implement the non-depreciated http-client!

All 7 comments

Do you get the same error when you use the js-ipfs-api module? https://github.com/ipfs/js-ipfs-api

Oh okay thanks it works with ipfs-api. Never thought of using it since it's deprecated.

I'll keep this issue open so we can try to implement the non-depreciated http-client!

@jonasbostoen This should work with the new release, 0.20.x. If you want to try it out, you can change your package json to this:

"dependencies": {
  "ipfs-http-client": "^30.0.0",
  "orbit-db": "orbitdb/orbit-db#feat/new-acs"
}

and you would set everything up and test it like this:

const OrbitDB = require('orbit-db')                   
const IpfsHttpClient = require('ipfs-http-client')

const ipfs = new IpfsHttpClient('0.0.0.0', '5001');

(async () => {
  const orbitdb = await OrbitDB.createInstance(ipfs, "./orbitdb");
  db = await orbitdb.keyvalue("test")                       
  await db.load()
  await db.set("key", "value")
  console.log(db.all())
})()

Awesome guys. Great work

Not able to install orbit version you specified

    "orbit-db": "orbitdb/orbit-db#feat/new-acs",

error:

npm ERR! code 1
npm ERR! Command failed: git checkout feat/new-acs
npm ERR! error: pathspec 'feat/new-acs' did not match any file(s) known to git.

Thanks for commenting @codeforgeek . Please try orbit-db@rc2 now as we've moved to release candidate for 0.20.0.

In your package.json:

"orbit-db": "rc2",
Was this page helpful?
0 / 5 - 0 ratings

Related issues

oskarpyke picture oskarpyke  路  6Comments

maroodb picture maroodb  路  4Comments

RichardLitt picture RichardLitt  路  4Comments

cristiano-belloni picture cristiano-belloni  路  5Comments

whyrusleeping picture whyrusleeping  路  3Comments