Corrupted files after Gateway timeout

Hello,

Im running a project where all files are stored on IPFS, its a portfolio where each artist add his creations.

Everything was working well untill tuesday, some images started to not load and were giving the following error:

“Failed to load resource: the server responded with a status of 504 (Gateway Timeout)”

After around 1h15 it came back to normal but a few image never fully loaded again and seem corrupted while they were working perfectly before.

They now load ether not at all or partially (always up to the same point) and give the following error:

Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH

What could have happened exactly?
i first though it was related to the gateway (infura) but the same issue happens if try to retrieve it from other gateway as well.

Is there any way to fix/retrieve the complete file?

Here an example of one of these corrupted file:

Image 1

My bet is that the files are partially cached in the gateways, but not fully.

Can you triple check that your IPFS node is running correctly, and reachable (ipfs id should show "/ipfs/kad/1.0.0" among the protocols)? I suggest re-starting it as well.

Hi Hector, thank you for the answer.

I don’t have a running node, only added it to infura gateway using the following code:

let host = "ipfs.infura.io";

const ipfsClient = require("ipfs-http-client");
let ipfs;

async function upload(file, callback) {

  ipfs = ipfsClient({
    host: host,
    port: "5001",
    protocol: "https",
  });

  const files = [{ path: "/"+file.name, content: file }];

  let progress_func = function(len) {
    callback({loaded:len, total: file.size})
  }; 

  try {

    let result = await ipfs.add(files, { progress: progress_func, pin: true, wrapWithDirectory: true })
    let cidv1 = new ipfsClient.CID(result.cid).toV1().toString();
    return { cid: { string: cidv1 } };

  } catch (err) {
    console.log("catched err");
    console.log(err);
    return { path: null, error: err };
  }
}

Files were quite recent, as they were added around UTC: 17.02.2021, 04:19:17 and were pinned.
Also the file were displaying correctly before this happened.

I see! You need to contact infura. It may be that not all the blocks that make up the files are being seeded or announed correctly to the network from their IPFS daemon.

Ok thank you, im also exchanging with their support about it but it was in case it could be something not related to them, thank you for the help.

hi @hector, thanks for helping us with this one.
We are investigating this on the Infura side, it doesn’t look to be an issue with our gateway. We’re trying to reproduce it though.
The images are uploaded properly via Infura gateway, correctly retrievable and then gone after a while.
When they cannot be loaded it’s not working neither with a gateway nor a local node.
In a day or two the file is back again online, it looks to happen with a few MB size images.

Traian

It also doesnt happen with every files added, its pretty random.

At the moment i have this one doing it:

https://bafybeiao53dpkaoa6trekqlejj6iwcmtdyx7buntde6654bsncbb3pnmwy.ipfs.infura-ipfs.io/display.JPG

This added file is only 156Kb so it seem to happens even on small size, was working at first then now is gone. Will reappear in a day or two, sometimes a bit faster.

Hello, still getting the issue here, identified these two at the moment:

Image 1

Image 2

Not really sure what can be done, what is sure is for like an hour or so after the add, the file is fully available on any gateway, before desappearing then coming back a day or two later.

When it disappear, it timeout on any gateway, not just infura.

Any idea @hector what could this be ? we are quite stuck here :confused: