Heroku Error R14 (Memory quota exceeded) running Node app

Viewed 575

The description gives me a pretty clear idea, what the error depends on. But I am not sure how to fix it. Do I have to pay for Heroku or can the issue be solved on the free version.

The script is very simple. I am collecting a lot of 3rd party API's, into one collected feed with pagination added.

So like this

const api = [];
Promise.all(
  endpoints.map((endpoint) =>
      fetch(endpoint)
      .then(res => res.json())
      .then(e => {
        // .... something
        return e;
      })
      catch(err => console.log(err)
).then(result => api.push(result)

app.get("/api", (req, res) => {
  let { size, page } = req.query;
  page = page * 20;
  size = page + 20;
  res.json(api.slice(page, size))
})

When the server is up and running local, it is working fine everytime. When I deploy it to Heroku, I get the Error R14 most of the times. Not all the times! If I refresh the page 4-6 times, it will receive the data.

0 Answers
Related