Random timeout on GET request with Axios

919 Views Asked by At

I have multiple sites buildt with static sites generator (gridsome, vue based).On build, they consume WP REST API data through Axios.

Lately, my build would fail a lot because Axios requests get randomly timedout.

Build log Axios

On the WP side, each request made by axios is returning a 200 response, the body of the response is well formed. Nothing odd. But Axios will randomly receive nothing...

WP REST API log

I don't know where to search since the requests are returning 200, what could go wrong between the response (being 200) and Axios ?

Additional clues :

  • I never have these timeout using postman, or my browser
  • The endpoints in WP REST API that timeouts are random
  • I use REST API LOG to monitor the states of the requests on WP side
  • No matter the timeout configured on axios, it just never get the response

Any help will be appreciated !

Thanks for your time

1

There are 1 best solutions below

0
Vincent Dilly On

This was an issue with Axios indeed. Axios in his 0.19 version returned timeouts where they might be other errors involved. I updated it to v0.22, that show me another error : some JSON response were truncated and not able to be parsed. Related issues on github :

I had to switch from axios to node-fetch.