Ipfs-http-client: Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed, when I make a call

Hi guys,

We created a simple wrapper class SubsocialIpfsApi around IPFS API. From this wrapper we make calls to get/add data from/to IPFS. We use such IPFS methods as “cat” and “add”.

When we make a call directly to IPFS from SubsocialIpfsApi class, everything works perfectly. But when make a call from another top-level wrapper SubsocialApi (it encapsulates both IPFS and Substrate API wrappers) we experiense an issue: the data displayed in the console inside the loop is returned, but the loop ends with an error:

const res = this.ipfs.api.cat(cids[0])
for await (const buf of res) {
    const content = JSON.parse(buf.toString())
Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed

An error is also generated when using the “it-all” package.

const promiseArray = ipfsCids.map(cid => all(this.api.cat(cid) as any));
const jsonContentArray = await Promise.all(promiseArray);

Also we opened issue on js-ipfs

1 Like

Any updates on this?