I have an API that executes a potentially long-running task that can take up to 10 minutes. This works fine when I hit the API from Postman, but when I use the API from a browser (Chrome, Safari, Firefox) the request times out before a response is received. The API is written in NodeJS/Express, and I have already increased the server's timeout. I have also increased the timeout on the javascript library I use to make the API call (request-promise). The API continues running and completes even after the request has timed out in the browser. How can I stop the request from timing out through the browser?
Asked
Active
Viewed 7,941 times
7
-
4long running requests like what you describe i would do separately by using a worker or a queue system then return message to user straight away. Perform task and then inform user (eg by messaging/sockets) that it has completed. – JimmyShoe Jul 30 '19 at 23:56
-
This answer might help you: https://stackoverflow.com/questions/5798707/browser-timeouts – user3486184 Jul 30 '19 at 23:56
-
1A 10 minutes task is too long for API, as @JimmyShoe said, you'd better use a `mq` or relative to replace current plan. – polunzh Jul 31 '19 at 01:56