0

I am creating a React Native app with Axios HTTP client, my backend is using express js with MySQL database, but I get randomly source exhausted prematurely error from my API.

I've tried to serve my express app using PM2 cluster to use all of CPU on my server but still doesn't work.

When the API is hit from Postman, everything is worked normally, but when it comes to App, it just got randomly source exhausted prematurely return.

How to solve this problem?

My environment:

  • React Native 0.61.4
  • Axios 0.19.0
  • Nginx webserver
  • MySQL database
  • Express 4.17.1

---Update---

The app working seamlessly if I run the express API locally using Nodemon (after fixing MySQL query I forgot to release connection on some query), but sometimes I still get source exhausted prematurely error when I run the express API from my server using PM2.

---Update---

It's getting better since applying the Nginx setting mentioned here: Node.js + Nginx - What now? But sometimes still get source exhausted prematurely error (I think now is 85% far better than before).

fxbayuanggara
  • 316
  • 3
  • 16

1 Answers1

0

I think I have solved the problem by:

  1. Turning on gzip on my API https://docs.nginx.com/nginx/admin-guide/web-server/compression/
  2. Fixing all of my express API res.send statement from res.send(JSON.stringify({ status: 200, error: null, response: results })); to res.status(200).send({ status: 200, error: null, response: results });. I think something wrong happens between Axios and Nginx (okhttp connection client) when I tried to get a JSON.stringify response from my express API.
fxbayuanggara
  • 316
  • 3
  • 16