[Solved] Once in a while, axios http long polling not returning at all


The problem was caused by occasional network issues.

I solved it by

  1. Adding a timeout to axios calls; for example: axios.get(url, {timeout: 18000}) for 18 seconds timeout. This is the main solution.
  2. Keeping a timestamp of when the last http request was started and check it regularly with setInterval(). If it was not tolerable, I starts a new “loop”. And also add handling if the number of long polling “loop” is too many and terminate the extra. I did this when I haven’t found the culprit.

Based on my observation, the actual time spent before exception is thrown might be several seconds (up to 5 seconds) longer than timeout duration given to axios.

solved Once in a while, axios http long polling not returning at all