Hi. Did you ever get to the bottom of this issue?
I am experiencing the same with your file … but found this post because I have the same issue with something kinda silly and definitely unexpected, which might help explain what was happening for you, though it’s not going to help.
If I create a file with contents …
contents = "Hello World 101"
… then I can ipfs cat
the resulting CID as expected.
However, if I add a file containing …
contents = "Hello World 101\n"
… then I experience the freeze, just like you.
The simple addition of a newline character \n
somehow causes a problem.
ipfs version 0.24.0
running on Ubuntu 22.04.3 LTS
More specifically …
/* eslint-disable no-console */
// this file is regular CommonJS
async function main () {
const { createHelia } = await import('helia')
const { unixfs } = await import('@helia/unixfs')
// create a Helia node
const helia = await createHelia()
// print out our node's PeerId
console.log(helia.libp2p.peerId)
// create a filesystem on top of Helia, in this case it's UnixFS
const fs = unixfs(helia)
// we will use this TextEncoder to turn strings into Uint8Arrays
const encoder = new TextEncoder()
// add the bytes to your node and receive a unique content identifier
const cid = await fs.addBytes(encoder.encode("Hello World 101\n"), helia.blockstore)
console.log('Added file:', cid.toString())
// this decoder will turn Uint8Arrays into strings
const decoder = new TextDecoder()
let text = ''
for await (const chunk of fs.cat(cid)) {
text += decoder.decode(chunk, {
stream: true
})
}
console.log('Added file contents:', text)
}
main().catch(err => {
console.error(err)
process.exit(1)
})
node indes.js
PeerId(12D3KooWQpZBeTmQ2VGZMBQkPX8bho8XiZ8rvoVZCYvqM71X49uR)
Added file: bafkreifjmburyvq23vcjz2vx4tpfu6zaogqe6fixzcrh2zqbnljzdg7zee
Added file contents: Hello World 101
^C
$ ipfs cat bafkreifjmburyvq23vcjz2vx4tpfu6zaogqe6fixzcrh2zqbnljzdg7zee
< freezes here, never to return to shell prompt >
If I remove the \n
then everything if fine …
node index.js
PeerId(12D3KooWHQDVUpSVQiEKx9pCiphcVqNJcGwhWDbYbFQthqEHbSVS)
Added file: bafkreife2klsil6kaxqhvmhgldpsvk5yutzm4i5bgjoq6fydefwtihnesa
Added file contents: Hello World 101
^C
$ ipfs cat bafkreife2klsil6kaxqhvmhgldpsvk5yutzm4i5bgjoq6fydefwtihnesa
Hello World 101