Question

App Platform memory heap error and page could not be served after deploy

Posted November 11, 2021 108 views
Node.jsDeploymentReactDigitalOcean App Platform

Hello! I deployed on App Platform yesterday and got a “Heap out of Memory” build error, which prevented my app from being deployed. After some online searching [1], I then added these 2 environment variables:

NODE_OPTIONS=--max-old-space-size=4096
GENERATE_SOURCEMAP=false

This caused my app to deploy successfully, but the Health App Check became “Unavailable” and when I tried to access my website, it displayed “We encountered an error when trying to load your application and your page could not be served. Check the logs for your application in the App Platform dashboard.”.

Anyone know what’s going on here?

[1] https://www.digitalocean.com/community/questions/app-platform-node-js-service-heap-out-of-memory

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hey there!

It sounds like your application may not actually have fully deployed if the health checks are failing. You will want to reference your application logs to see the errors being provided there. The message We encountered an error when trying to load your application and your page could not be served" typically indicates a 5xx error of some kind. Your logs should provide more details on it. You can also open your browser developer console and check the error shown there.

For the health checks you will want to make sure your application is set to listen on 0.0.0.0 and not 127.0.0.1 or localhost. You’ll also want to ensure you aren’t running any long migrations or other processes during the deploy that may prevent your application from being able to respond to health checks. You can move those to post deploy jobs instead.

Lastly if needed you can modify the health checks to start at a later time. You would need to edit the intial_delay_seconds to increase the amount of time before health checks start.

Hope it helps!
Nate