Error ipfs.add timeouts and then gives hash

Hello i am using IPFS infura to add file on IPFS , the code was working fine till yesterday but today whenever i try to upload file using ipfs.add , i get timeout exception and also the hash .
the problem here is that timeout exception that i get is not coming in the catch block
so i get a exception and then i get hash also , very weried

Hi Vijayta, welcome to the Infura Community!

Could you provide the code you’re using to send the add request and the error responses you are seeing?

Hello mike ,
the code that i am using is

const IPFS = require(‘ipfs-mini’);

const ipfs = new IPFS({ host: ‘ipfs.infura.io’, port: 5001, protocol: ‘https’ });

ipfs.add(“testing data”).then((result) => {
}));

Thanks are you also getting error responses, can you provide those if so.

502 gateway timeout

it is very random and unpredictable

Can you provide the full error response?

from morning again down getting two types of error

  1. Error: [ipfs-mini] status 500: {“Message”:“open /data/ipfs/blocks/C2/put-902349971: too many open files”,“Code”:0,“Type”:“error”} at exports.XMLHttpRequest.request.onreadystatechange (/srv/node_modules/ipfs-mini/src/index.js:63:20) at exports.XMLHttpRequest.dispatchEvent (/srv/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25) at setState (/srv/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14) at IncomingMessage. (/srv/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13) at emitNone (events.js:111:20) at IncomingMessage.emit (events.js:208:7) at endReadableNT (_stream_readable.js:1064:12) at _combinedTickCallback (internal/process/next_tick.js:139:11) at process._tickDomainCallback (internal/process/next_tick.js:219:9) more_vert

  2. Error: [ipfs-mini] status 504: 504 Gateway Time-out

    504 Gateway Time-out

    at exports.XMLHttpRequest.request.onreadystatechange (/srv/node_modules/ipfs-mini/src/index.js:63:20) at exports.XMLHttpRequest.dispatchEvent (/srv/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25) at setState (/srv/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14) at IncomingMessage. (/srv/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13) at emitNone (events.js:111:20) at IncomingMessage.emit (events.js:208:7) at endReadableNT (_stream_readable.js:1064:12) at _combinedTickCallback (internal/process/next_tick.js:139:11) at process._tickDomainCallback (internal/process/next_tick.js:219:9)

Can you test this again? We made some small changes to our IPFS nodes this morning.

It is working now mike,
but as you see i am facing this random issues since last few days .
sometimes it work , sometimes it doesn’t , we cant rely like this

what is the issue there? and why does it work randomly ?

This is a known issue we are working on addressing a permanent solution. We greatly appreciate your patience and will be releasing major updates to our IPFS service soon.

Do you know when you will have a permanent solution? We just need a timeline because we need this to be consistent for our service. Thank you.

This will depend on your specific use case, but it is possible now to use HTTP Basic Auth when sending your IPFS requests to Infura. If you switch your requests to using a Project ID and Project Secret as HTTP Basic Auth, we can assess your requests and get better information on where you may be seeing issues.

Hi Mike i am facing the same issue of ReqTimeOut while adding file to ipfs, here is my code snippet

const fileAdded = await ipfs.add({
            path: filePath,
            content: fileBuffer
        });

@Zombie can you provide the full error response and details about the file you’re trying to add (size, etc.)?

@mike thanks for the response, the size of file is almost 500 bytes and the file is in .json format
and the error is Error: TimeoutError: Request timed out

Does your code attempt to add again upon receiving an error, if so, did this result in multiple errors?

@mike no, there is my code snippet

const fs = require('fs');
const ipfs = require('../config/ipfs.config').ipfs;
const ipfsModel = require('../app/models/ipfs-hash.model');

exports.addFileIPFS = async (fileName, filePath) => {
    try {
        const fileBuffer = fs.readFileSync(filePath);
        const fileAdded = await ipfs.add({
            path: filePath,
            content: fileBuffer
        });
        console.log('file added : ', fileAdded);
        const fileHash = fileAdded[0].hash;
        if (fileHash) {
            const createIPFSFileHash = new ipfsModel({
                did: fileName,
                ipfsHash: fileHash
            });
            console.log('saving ipfs hash...')
            const saveFileHash = await createIPFSFileHash.save();
            if (saveFileHash) {
                return fileHash;
            }
        } else {
            throw new Error('IPFS Hash not found');
        }
        // console.log(fileHash);
        // return fileHash;
    } catch (error) {
        // console.log(error);
        throw new Error(error);
    }
}

I would recommend adding some error handling that attempts to re-add the content. This should help to ensure that whether there is a problem on the client side or the API side the content has a better chance of getting added.