I have an excel sheet with data and I am processing it after reading the data. The problem is that, even though the processing is not done it, the request gets timed out in postman.
xlsxj({
input: filepath,//path of the file
output: null, // I am not taking any output of the file
sheet: "Party Master"
}, async function (err, result) {
if (err) {
res.send(err);
} else {
try {
for(let row of result) { // more than 1000 iterations
await fun1(row);
await fun2(row);
await fun3(row);
}
return res.send('all done');
}
catch(err){
console.log(err);
}
}
})
where am I getting wrong?
You're API timeout because file processing is taking time. If you are using express framework the default API timeout is 2 min what you can do is increase the timeout of the API.
If you are using express then you can simply do
req.setTimeout(500000); // time in ms
I have found a solution. Return the response in finally block.
xlsxj({
input: filepath,//path of the file
output: null, // I am not taking any output of the file
sheet: "Party Master"
}, async function (err, result) {
if (err) {
res.send(err);
} else {
try {
for(let row of result) { // more than 1000 iterations
await fun1(row);
await fun2(row);
await fun3(row);
}
return res.send('all done');
}
catch(err){
console.log(err);
}
finally{
return res.send('all done')
}
}
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.