ipfs / js-ipfs

IPFS implementation in JavaScript
https://js.ipfs.tech
Other
7.44k stars 1.25k forks source link

ERR_PUTTING_TO_ROUTING #4023

Closed ki4jgt closed 1 year ago

ki4jgt commented 2 years ago

Severity:

High

Description:

Building a P2P blockchain based blogging/calling/messaging/coding platform. Whenever I attempt to publish a CID as the profile index, the application crashes with ERR_PUTTING_TO_ROUTING

Steps to reproduce the error:

Code:

async _broadcast(dir){
        var list = []
        for await (var chunk of this.node.files.ls("/")) list.push(chunk)
        for (const file of list){
            if (file.name == "profile"){
                this.node.name.publish(String(file.cid))
            }
        }
    }

Produces:

C:\Users\marye\onedrive\desktop\parcel\node_modules\ipfs-core\cjs\src\ipns\publisher.js:92
      throw errCode__default["default"](new Error(errMsg), 'ERR_PUTTING_TO_ROUTING');
                                        ^

Error: ipns record for f5uxa3ttf4acicabciqgw6cqgwukfdqibrjgxcxuuwmg3ceymjbny7guhtmn7lwzecsciwy could not be stored in the routing
    at IpnsPublisher._publishEntry (C:\Users\marye\onedrive\desktop\parcel\node_modules\ipfs-core\cjs\src\ipns\publisher.js:92:41)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async IpnsPublisher._putRecordToRouting (C:\Users\marye\onedrive\desktop\parcel\node_modules\ipfs-core\cjs\src\ipns\publisher.js:67:5)
    at async IPNS.publish (C:\Users\marye\onedrive\desktop\parcel\node_modules\ipfs-core\cjs\src\ipns\index.js:32:7)
    at async publish (C:\Users\marye\onedrive\desktop\parcel\node_modules\ipfs-core\cjs\src\components\name\publish.js:67:20) {
  code: 'ERR_PUTTING_TO_ROUTING'
}

Thanks for this great project, guys.

welcome[bot] commented 2 years ago

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:

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

ki4jgt commented 2 years ago

bump

ki4jgt commented 2 years ago

Just tried in 0.62.0, and got the same error.

ki4jgt commented 2 years ago

Problem resolved: I had a custom repo in ipfs.create()

ipfs.create({repo: __dirname+"data"})

No longer an issue, but I'd love the ability to have a custom repo, as my app will be distributed as an exe.

noryev commented 2 years ago

Thanks for figuring this out. I was getting this "ERR_PUTTING_TO_ROUTING" error in IPNS too and behold its the same problem as you-

ki4jgt commented 2 years ago

It came back a couple days later. I'm writing a registration server for my project because of this.

jtmckay commented 2 years ago

I'm writing an app using js-ipfs (which is awesome tech! Thank you all!) but I have yet to find a path to success using IPNS. I spent many hours troubleshooting, and decided to go back to square one.

Using the js-ipfs-examples/examples/ipfs-101 I added one line: await node.name.publish(file.cid) after the last console.log which results in the above error. Which leads me to believe that this is not possible in js-ipfs, and we must rely on go-ipfs. Based on a blurb in the README of the browser-ipns-publish example "To get our IPNS record to the DHT, we'll need a server running go-IPFS with the API enabled on port 5001."

If it actually is possible to publish with only js-ipfs, or it is made possible, please let me know. I'm exploring alternatives without it.

jwahdatehagh commented 2 years ago

Having the same issue. Which is super weird as it first worked but stopped now...

legalizemath commented 1 year ago

Running npm package ipfs-core i.e. js-ipfs 0.15.4 on Ubuntu 22.04 LTS, Node v16.16.0, npm 8.11.0

nodejs ipfs node using IPNS publish often works fine at first (& fully separate browser ipfs node can resolve it), but then nodejs starts to fail with ERR_PUTTING_TO_ROUTING on republishing it every 20 minutes as suggested by many up to hundreds of times in a row with very rare times it succeeds. (other nodes usually fail resolving it during this) I tried all kinds of .create({}) instance options including none, nothing seems to help. I basically done no customization of any kind, just npm i ipfs-core

typical error e.g.

Error: ipns record for f5[redacted]pq could not be stored in the routing - Error: Write failed
file:///root/[redacted]/node_modules/ipfs-core/src/ipns/publisher.js:94
      throw errcode(new Error(errMsg), 'ERR_PUTTING_TO_ROUTING')

example of typical code removing everything irrelevant.

import * as ipfsCore from 'ipfs-core'
import { inspect } from 'node:util'
const ipfs = await ipfsCore.create({
    Routing: { Type: 'dht' },
    Pubsub: { Router: 'gossipsub', Enabled: true },
    EXPERIMENTAL: { ipnsPubsub: true },
    Ipns: { UsePubsub: true },
    dht: true
})
const resAdd = await ipfs.add('random byte data')
const { cid } = resAdd // grab cid
while (true) {
  try {
    const resPublish = await ipfs.name.publish(cid) // just under default self key
    console.log(inspect(resPublish))
  } catch(e) { console.error(e) }
  // wait 21 minutes (tried doing this more and less often too)
  await new Promise(res => setTimeout(res, 21 * 60 * 1000))
}

this will result in hundreds of times more ERR_PUTTING_TO_ROUTING errors than successful updates

I did notice that it works more often soon after initializing the node rather than later so I tricked it into working as often as 1 in 1-8 attempts simply by running await ipfs.stop(); await ipfs.start() few seconds before reattempting publishing (vs default ~1 in 10s or 100s of attempts)

I'm guessing having to restart node everytime you want to publish wasn't the intended design, just thought I'd provide more details and that it does in fact work sometimes so maybe it helps you track it or give suggestions on options to set

algorista commented 1 year ago

I found the source of the bug and posted a solution. it's in the issue https://github.com/ipfs/js-ipfs/issues/4267

SgtPooki commented 1 year ago

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).

Assigning to @achingbrain to answer whether this issue is already resolved in Helia, or if this issue needs to be migrated to that repo!

achingbrain commented 1 year ago

Please see this comment on #4267 - in a nutshell this error happens when the publishing node has insufficient network connectivity. Either not enough connections or they cannot dial peers, etc, which means the attempt to publish the record fails.

This situation will improve over time as more of the non-js network upgrades to support newer transports like WebRTC and WebTransport which means js can dial more peers.