R
Railway13mo ago
Kurdiez

Deploy Logs show out of heap memory

My server runs fine locally, but only in Railway it fails to deploy and shows the following attached messages. The build phase works fine.
Solution:
Ok, now that's working great after getting 32GB
Jump to solution
31 Replies
Percy
Percy13mo ago
Project ID: 00a98625-f237-4950-bfaa-f6b77695df8c
Kurdiez
KurdiezOP13mo ago
00a98625-f237-4950-bfaa-f6b77695df8c I made sure the node version is the same as my local with environment variable NIXPACKS_NODE_VERSION which is version 18
Brody
Brody13mo ago
I'm seeing nodejs-20.6.1 in multiple places in those logs
Kurdiez
KurdiezOP13mo ago
Oh sorry that is an old log. Let me get you new one with the NIXPACKS_NODE_VERSION update.
Brody
Brody13mo ago
what do your memory metrics look like
Kurdiez
KurdiezOP13mo ago
Oh weird... Even though my build log says I'm using nodejs_18 at the top, my deployment log has 20 like you said.
Kurdiez
KurdiezOP13mo ago
I guess docker runtime environment is Node 20?
Brody
Brody13mo ago
1.9gb image?? what do your memory metrics look like
Kurdiez
KurdiezOP13mo ago
Where did you see 1.9gb image?
Brody
Brody13mo ago
your build logs
Kurdiez
KurdiezOP13mo ago
Oh you mean the docker image. When I start up my server locally, it uses up about 1GB of RAM memory.
Brody
Brody13mo ago
what do your memory metrics look like on railway
Kurdiez
KurdiezOP13mo ago
My server never started up properly. The out of memory message shows up immediately when yarn start is executed.
No description
Brody
Brody13mo ago
fair
Kurdiez
KurdiezOP13mo ago
My guess is that the Memory metrics is the memory usage during the run time of the server?
Brody
Brody13mo ago
increase the heap size?
Kurdiez
KurdiezOP13mo ago
I can but that worries me. I've used Railway for multiple projects with similar code base and never had to do that. Weird... I will try increasing the heap size.
Brody
Brody13mo ago
not really sure what to tell you then, this isn't an issue with Railway and there's not much to go off of
Kurdiez
KurdiezOP13mo ago
True Trying now with increased heap size what's the max heap size we get anyway?
Brody
Brody13mo ago
whatever the default for node 18 is
Kurdiez
KurdiezOP13mo ago
I mean from Railway. Per docker container
Brody
Brody13mo ago
I know if you're asking about ram, that's 8gb as per your plan
Kurdiez
KurdiezOP13mo ago
ok thanks I tried 4GB and the there wasn't enough system memory and got killed
yarn run v1.22.19
$ NODE_OPTIONS='--max-old-space-size=4096' TZ=UTC nest start
Killed
error Command failed with exit code 137.
yarn run v1.22.19
$ NODE_OPTIONS='--max-old-space-size=4096' TZ=UTC nest start
Killed
error Command failed with exit code 137.
Kurdiez
KurdiezOP13mo ago
Does running a Postgres with the server service have an impact on the system RAM?
No description
Kurdiez
KurdiezOP13mo ago
Trying out 2048 (2GB) now. Yeah 2048 also gets killed immediately... as well with code 137 @Brody Could I get some help why my current plan on Railway allows up to 8GB RAM but I can't give even 2GB to my Node server when I start it up? Ok I'm gonna pay the $20 and try to get the 32GB RAM per service and see if I get start the server with enough memory... If getting the Railway Pro and it doesn't solve the issue I honestly don't know what to do at this point...
Solution
Kurdiez
Kurdiez13mo ago
Ok, now that's working great after getting 32GB
Brody
Brody13mo ago
was sleeping, but some things to note
Does running a Postgres with the server service have an impact on the system RAM?
nope, each service can use up to what your plan allows for
Could I get some help why my current plan on Railway allows up to 8GB RAM but I can't give even 2GB to my Node server when I start it up?
I honestly wouldn't know
Ok, now that's working great after getting 32GB
guess that means your app was trying to allocate more than 8gb of ram during start? what does the app do during start?
Kurdiez
KurdiezOP13mo ago
My app doesn't do anything. I did a memory profiling using chrome://inspect to take heap dump and it said (string) and (compiled code) takes the most amount of memory. I guess all the libraries I am installing brings in so much crap. On the side note... now I am having hard time exposing my server public. My server binds to the port specified by PORT environment variable. I now added the PORT env variable in Server settings and trying to see if I can access the server using that port.
Brody
Brody13mo ago
you can only access your http app externally via https on port 443 give this a read https://docs.railway.app/troubleshoot/fixing-common-errors
Kurdiez
KurdiezOP13mo ago
ah ok got it thanks. It's all working now.
Brody
Brody13mo ago
awesome!
Want results from more Discord servers?
Add your server