Skip to content

TypeError: Cannot read properties of undefined (reading 'addEventListener') #8

@codeicey

Description

@codeicey

I was trying out second usage in liftoff docs and ran into this error:

Steps to reproduce

`
import { createOrbitDB } from "@orbitdb/core";
import { createLibp2p } from "libp2p";
import { createHelia } from "helia";
import { DefaultLibp2pOptions } from "@orbitdb/liftoff";

const libp2p = createLibp2p({ ...DefaultLibp2pOptions });
const ipfs = await createHelia({ libp2p });

const orbitdb = await createOrbitDB({ ipfs });

const db1 = await orbitdb.open("db1");
await db1.add("hello world!");
console.log(await db1.all());
`

Error log

`
file:///home/runner/orbit/node_modules/@orbitdb/core/src/sync.js:276
pubsub.addEventListener('subscription-change', handlePeerSubscribed)
^

TypeError: Cannot read properties of undefined (reading 'addEventListener')
at startSync (file:///home/runner/orbit/node_modules/@orbitdb/core/src/sync.js:276:14)
at async Sync (file:///home/runner/orbit/node_modules/@orbitdb/core/src/sync.js:286:5)
at async Database (file:///home/runner/orbit/node_modules/@orbitdb/core/src/database.js:188:16)
at async file:///home/runner/orbit/node_modules/@orbitdb/core/src/databases/events.js:19:20
at async Object.open (file:///home/runner/orbit/node_modules/@orbitdb/core/src/orbitdb.js:156:16)
at async file:///home/runner/orbit/index.js:11:13

Node.js v20.18.1
`

Package.json and IDE

IDE: Replit

Package.json

`
{
"name": "nodejs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"type": "module",
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@orbitdb/core": "^2.4.1",
"@orbitdb/liftoff": "^1.1.0",
"@types/node": "^18.0.6",
"helia": "^5.1.0",
"libp2p": "^2.4.2"
}
}

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions