js-ipfs icon indicating copy to clipboard operation
js-ipfs copied to clipboard

js-ipfs 0.63.2 WebRTCStar under node.js 16.15.1 IPFS.create() Promise never resolve nor reject

Open eltorio opened this issue 3 years ago • 2 comments

PROBLEM: IFS.create() promise never resolve nor reject Context: With the latest js-ipfs (0.63.2) under node.js 16.15.1 LTS and wrtc 0.4.7 Workaround Remove the two WebRTCStar listening addresses

        '/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star',
        '/dns4/wrtc-star2.sjc.dwebops.pub/tcp/443/wss/p2p-webrtc-star'

run with

npx ts-node --esm tests/simple.ts

Testing code:

import * as IPFS from 'ipfs-core'
import all from 'it-all'
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
import wrtc from 'wrtc'
import { WebRTCStar } from '@libp2p/webrtc-star'
import { MulticastDNS } from '@libp2p/mdns'
import { Bootstrap } from '@libp2p/bootstrap'

const FILE = '/ipfs/QmRaaUwTNfwgFZpeUy8qrZwrp2dY4kCKmmB5xEqvH3vtD1/readme'
const webRtcStar = new WebRTCStar({ wrtc })

IPFS.create({
  repo: './tmp',
  start: true,
  EXPERIMENTAL: {
    ipnsPubsub: true
  },
  config: {
    Addresses: {
      Swarm: [
        '/ip4/0.0.0.0/tcp/4002',
        '/ip4/127.0.0.1/tcp/4003/ws',
        '/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star',
        '/dns4/wrtc-star2.sjc.dwebops.pub/tcp/443/wss/p2p-webrtc-star'
      ]
    }
  },
  libp2p: {
    transports: [
      webRtcStar
    ],
    peerDiscovery: [
      webRtcStar.discovery,
      new MulticastDNS({
        interval: 1000
      }),
      new Bootstrap(
        {
          list: [
            '/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN',
            '/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa',
            '/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb',
            '/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt',
            '/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ',
            '/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ'
          ],
          interval: 2000
        }
      )
    ]
  }
}).then((ipfs) => {
  all(ipfs.cat(FILE)).then((u8data) => {
    console.log((new TextDecoder()).decode(uint8ArrayConcat(u8data)))
    ipfs.stop().then(() => {
      console.log('ended')
    })
  })
}).catch((reason) => { console.log(reason) })

package.json

{
  "scripts": {
    "dev": "nodemon --watch src -e js,ts,json --exec \"ts-node --esm src/index.ts\"",
    "build": "tsup-node --format esm src/index.ts --clean",
    "start": "node dist/index.js",
    "test": "ts-node test.ts"
  },
  "devDependencies": {
    "@types/cacheable-request": "^6.0.2",
    "@types/cors": "^2.8.12",
    "@types/events": "3.0.0",
    "@types/express": "^4.17.13",
    "@types/node": "^17.0.42",
    "@types/orbit-db": "github:orbitdb/orbit-db-types",
    "@typescript-eslint/eslint-plugin": "^5.28.0",
    "@typescript-eslint/parser": "^5.28.0",
    "eslint": "^8.17.0",
    "eslint-config-standard": "^17.0.0",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-n": "^15.2.2",
    "eslint-plugin-promise": "^6.0.0",
    "ipfs-core-types": "^0.11.0",
    "nodemon": "^2.0.16",
    "npm-check-updates": "^13.1.5",
    "ts-node": "^10.8.1",
    "tsconfig-paths": "^4.0.0",
    "tsup": "^6.1.2",
    "typescript": "^4.7.3"
  },
  "dependencies": {
    "@chainsafe/libp2p-gossipsub": "^1.1.2",
    "cors": "^2.8.5",
    "express": "^4.18.1",
    "ipfs": "^0.63.2",
    "wrtc": "^0.4.7"
  },
  "engines": {
    "node": "16.x"
  },
  "type": "module"
}

tsconfig.json

{
  "compilerOptions": {
    "baseUrl": ".",
    "target": "esnext",
    "module": "esnext",
    "lib": [
      "ES2020",
      "dom",
      "dom.iterable",
      "scripthost"
    ],
    "allowJs": true,
    "allowSyntheticDefaultImports":true,
    "moduleResolution": "Node",
    "esModuleInterop": true,
    "strict": false,
    "noEmit": true,
    "strictNullChecks": true,
    "resolveJsonModule": true,
    "skipDefaultLibCheck": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "outDir": "./dist",
    "strictPropertyInitialization": false,
    "paths": {
      "~/*": [
        "./src/*"
      ],
      "~~/*": [
        "./*"
      ]
    },
    "typeRoots": [
      "./src/types",
      "./node_modules/@types"
    ]
  },
  "ts-node": {
    "require": [
      "tsconfig-paths/register"
    ]
  },
  "include": [
    "src/**/*.ts",
    "tests/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ]
}

eltorio avatar Jun 14 '22 16:06 eltorio

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review. In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment. Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

welcome[bot] avatar Jun 14 '22 16:06 welcome[bot]

When this appears the only way to restart is to delete the repo. I tried to add repoAutoMigrate: true but it does not help

eltorio avatar Jun 14 '22 17:06 eltorio

js-ipfs is being deprecated in favor of Helia. You can https://github.com/ipfs/js-ipfs/issues/4336 and read the migration guide.

Please feel to reopen with any comments by 2023-06-02. We will do a final pass on reopened issues afterward (see https://github.com/ipfs/js-ipfs/issues/4336).

This issue is most likely resolved in Helia (and the latest versions of libp2p), please try it out!

SgtPooki avatar May 26 '23 19:05 SgtPooki