I am running a Node.js (v22) application on docker with a Vue 3 front-end. The application works fine except it has crashed randomly which I cannot work out why it happens. I had a look at the docker log for the container and I can see that it basically starts timing out after this:
{"log":"onServerPrefetch ran getProduct(14425)n","stream":"stdout","time":"2024-06-19T16:46:29.289530937Z"}
{"log":"onServerPrefetch ran getProduct(14430)n","stream":"stdout","time":"2024-06-19T16:46:29.303259316Z"}
{"log":"onServerPrefetch ran getProduct(14427)n","stream":"stdout","time":"2024-06-19T16:46:29.315447855Z"}
{"log":"onServerPrefetch ran getProduct(14417)n","stream":"stdout","time":"2024-06-19T16:46:29.32901105Z"}
{"log":"onServerPrefetch ran getProduct(14419)n","stream":"stdout","time":"2024-06-19T16:46:29.346483497Z"}
{"log":"onServerPrefetch ran getProduct(14433)n","stream":"stdout","time":"2024-06-19T16:46:29.370365608Z"}
{"log":"onServerPrefetch ran getProduct(14424)n","stream":"stdout","time":"2024-06-19T16:46:29.382479396Z"}
{"log":"onServerPrefetch ran getProduct(14417)n","stream":"stdout","time":"2024-06-19T16:46:29.395289652Z"}
{"log":"onServerPrefetch ran getProduct(13182)n","stream":"stdout","time":"2024-06-19T16:46:29.477117327Z"}
The above log means that Vue’s onServerPrefetch() ran and is resolved before the page is rendered on the server. That is then served to the browser via Express.
After the above has occured I get the following error from the console.error log:
{"log":"ProductView.vue error: AxiosError: timeout of 120000ms exceededn","stream":"stdout","time":"2024-06-19T16:48:29.311004059Z"}
So when someone or something has made multiple different requests to view Products on the application, it causes a crash of some kind. I am not sure what has crashed exactly but Axios
no longer gets any data from the API running on the same Node server.
Is there any global setting I can enable to limit how many requests can be made in a second to the server to see if that is the problem or does anyone know what the might problem might be?