novu icon indicating copy to clipboard operation
novu copied to clipboard

🐛 Bug Report: Web Docker container gets existed with JavaScript heap out of memory

Open chavda-bhavik opened this issue 1 year ago • 10 comments

📜 Description

When using self-hosted version of Novu, many times docker container for Web gets terminated with error FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory. js-memory-heap log

👟 Reproduction steps

Deploy Novu on Ubuntu instance with Ubuntu version: 22.04 LTS and 11 GB RAM, and start using it.

👍 Expected behavior

It should work smoothly.

👎 Actual Behavior with Screenshots

Web container gets terminated with error FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory. js-memory-heap log

💻 Operating system

Linux

🤖 Node Version

v16.15.1

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • [X] I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

Yes I am willing to submit a PR!

chavda-bhavik avatar Nov 02 '22 11:11 chavda-bhavik

Could you provide more logs from the container of what was being executed before running out? Thus will make it easier to investigate. What was the running time of the container before terminating for the memory error?

p-fernandez avatar Nov 02 '22 15:11 p-fernandez

@p-fernandez I couldn't able to find exact timing for start and end of container but it happened two times, one was after 2 month and another was after 1 day. And Docker logs showing the same entries of the image I attached previously.

chavda-bhavik avatar Nov 03 '22 03:11 chavda-bhavik

Hey, @scopsy @p-fernandez Any update on this issue? I can spare some time on it if you can provide some hints on possible ways to tackle this issue.

chavda-bhavik avatar Nov 14 '22 06:11 chavda-bhavik

Hi @chavda-bhavik, I would mainly suggest to think of a different static content serving options instead of the simple-http server npm package we use there. Maybe we can use NGINX? Or any other static serving solution?

Internally we use Netlify, so we don't experience any problems with it. But previously I have used nginx for static files so maybe it will also work here. Wdyt?

scopsy avatar Nov 14 '22 07:11 scopsy

Didn't tried serving static content with Nginx before, But I will look into it. @scopsy can you assign this issue to me?

chavda-bhavik avatar Nov 14 '22 07:11 chavda-bhavik

@chavda-bhavik I think I actually noticed that it happens during the initialization of the container right? Seems like the build command is the one that is failing. If this is the case, you would need to provide a bit more RAM for your docker daemon that running the web component

scopsy avatar Nov 27 '22 12:11 scopsy

@scopsy RAM can be the reason for this issue. Actually memory error was happening some days after the application started. And from my observation on apps/web/Dockerfile, it looks like build will be happening during docker image creation time, instead of container initialization time, Am I right?

chavda-bhavik avatar Nov 28 '22 04:11 chavda-bhavik

Yes, we are doing initialization time build because we need to compile some environment variables and inject them there. We might need to revisit this in the future as it's not the best approach.

scopsy avatar Nov 29 '22 07:11 scopsy

Hey, @scopsy I have been busy nowadays, I will look into it as I got some time.

chavda-bhavik avatar Dec 05 '22 11:12 chavda-bhavik

@scopsy Why do you think it is an issue at build time? The service seems to be running successfully before it crashes, making it a runtime issue. Or am I missing something here?

pascal-mueller avatar Dec 13 '22 10:12 pascal-mueller

A deploy was made that should help address this in the prebuilt 0.11.0 version. @chavda-bhavik please let me know if you still see this when running the 0.11.0

Closing this for now 🙏

scopsy avatar Feb 05 '23 17:02 scopsy