I have a server that converts large files and uploads the results to cloud storage. Today I finally hit that limit, where conversion took over a minute and upload took 2 more, resulting in a very long HTTP request. Client is React using axios to call an Express server.
What I'm experiencing on the server side is that after about 2 minutes, the request gets called again (with no user input). Both requests then fail on the client (yet succeed on the server). The result is 2 conversions of the same file, and 2 useless uploads, since the client gets notified of an error.
I believe that what I'm seeing is a try-timeout-abort-retry-timeout-abort sequence. I tried passing a {timeout: 5 * 60 * 1000} to axios to get 5 minutes timeout - to no avail.
We're planning to change the process to be async, out-of-band, Web Sockets, etc. But until then, how can I ensure the request won't fail? Is there a browser-level setting I need to handle? Or use a different library than axios?
Thanks to all the comments - you guys nailed it. The abort was issued by Express. Adding req.setTimeout(5 * 60 * 1000) solved it. Thanks all!
Update: adding the timeout at the server level is even better:
//...express middleware + routs + etc...
const server = app.listen(PORT, function() {
console.log(`listening on ${PORT}`);
});
//set timeout of requests to 5 minutes
server.timeout = 5 * 60 * 1000;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With