Cold Start Issue

Hello, I recently deployed a NodeJS server on Railway that acts as the backend to a React App that I'm hosting on Vercel, but I'm facing an issue of the server going to sleep after enough time passes by with inactivity. How can I fix this? The server needs to be ready to serve content at all times.
20 Replies
Percy
Percy12mo ago
Project ID: N/A
angelplusultra
angelplusultra12mo ago
n/a
Fragly
Fragly12mo ago
App Sleeping isn't enabled right?
angelplusultra
angelplusultra12mo ago
I don't see that setting in the server configuration settings, do you know where I could find that?
Brody
Brody12mo ago
it's in the service settings, it's off by default and if you don't know about it then it's still off when it's off, there is no cold starts
angelplusultra
angelplusultra12mo ago
Its not in the settings, i'm looking at the docs exactly where the screenshot says it should be (right next to the healthcheck settings) and its not there. If theres no cold starts then does anyone here have an idea why this could be happening with my application?
Brody
Brody12mo ago
my first thoughts are after a while the idle timeout for your database passes and then on the next request your app has to reconnect to the database it's not in the settings because it's a beta feature, but like I said it's off by default
angelplusultra
angelplusultra12mo ago
Is it something I can fix within the frontend? It's hard to debug because once the server is up and running the bug wont reproduce for another couple hours or so and the timeout occurs again.
Brody
Brody12mo ago
no this is backed related, are there errors in the backend? and what kind of Backend is it?
angelplusultra
angelplusultra12mo ago
Strapi CMS w/ NodeJS
Brody
Brody12mo ago
send your database.js
angelplusultra
angelplusultra12mo ago
Connection Error: Connection ended unexpectedly This is in my logs when I made the request and it failed the initial request, everything after is 200
Brody
Brody12mo ago
angelplusultra
angelplusultra12mo ago
GitHub
calm-shrub-website/server/config/database.js at main · angelplusult...
a website for the artist, Calm Shrub. Contribute to angelplusultra/calm-shrub-website development by creating an account on GitHub.
angelplusultra
angelplusultra12mo ago
here is my database.js revise the pool field?
Brody
Brody12mo ago
set pool.min to 0 as shown by the database.js file I linked
angelplusultra
angelplusultra12mo ago
I will try that out, thank you for the suggestion
Brody
Brody12mo ago
if done right, this will work, it's mentioned in strapis docs
Brody
Brody12mo ago
in fact I'm confident enough to do this
Want results from more Discord servers?
Add your server