Error: application failed to respond railway
Hello!
I am new to railway. My deployment was crashed and deploy log said- "The build failed because the process exited too early. This probably means the system ran out of memory or someone called
kill -9
on the process."
I am getting an error - "application failed to respond railway" on my domain.179 Replies
Project ID:
N/A
what kind of app are you trying to deploy? its possible its trying to use more than the 512mb of memory you get on the trial plan
I made a realtime code editor using websocket and nodejs
is it possible its trying to use more than 512mb of memory? whats your tech stack?
react , node
create react app?
yes
is the backend a seprate railway service?
no
an express api thats also serving the frontend?
yes sir
would you be interested in me walking you through how to properly deploy that kind of app to railway? it would require some code changes
ok sure
I am quite new! I m sorry
no worries, we will take this one step at a time and as we go it will all make sense, trust the process
Should i share my repo link?
yes please
and to start us off, a screenshot of your railway project
just so i know whats up
GitHub
GitHub - 4vinn/cypher-code-editor
Contribute to 4vinn/cypher-code-editor development by creating an account on GitHub.
ss of my logs?
of the railway project, aka your browsers viewport
go ahead and remove the repo from that service from within its settings page
done
another screenshot please
you removed the service itself
close enough
ohh
should i add the service again
nah we will do it later
what should I do?
for now you need to restructure your repo into a monorepo, that would look like this
ok
just a sec
no worries, take your time
done
@Brody
remove the code from the backend that used the serve the frontend
fix up each package.json, you still have scripts that run stuff that are for the other app, and you have dependencies for the other app too
so we will serve frontend and backend differently
Separately*
correct, they will be separate railway services
@Brody can you please check now?
your lock files arent in sync
run
npm install --package-lock-only
in both folderscheck now
last change was 9 minutes ago
it gave me "1 high severity vulnerability" in frontned
youll have that sometimes
check now sire
https://github.com/brody192/create-react-app-starter
copy the nixpacks.toml and Caddyfile from this repo into your frontend folder
ok...may i know what are these?
for sure, caddy is an enterprise ready web server, it will serve your frontend
the nixpacks.toml sets it up, and the Caddyfile configures it to serve the react app
i added the files
remove the .txt extension please
didn't get the gist of it, but ok 🙂
trust the process, remember 😉 ive done this a hundred times
done
okay i think its time to deploy the frontend
i mean I dont doubt you, its just a lot for me to understand...i just got in this field 😦
add a new empty service to your project
ok
for the nexts steps can you send a screenshot each time? just so i know things are going smoothly
ok
i added an empty service
is it ok?
in its settings, set the root dir to
/frontend
done
give it an good name like
Cypher Code Editor - Frontend
and generate yourself a domaindone
add your repo to the service
in this service?
yep
how? 😅
look through the settings, you will see an option to add your repo
connect repo option?
yep
done
but nothing happened
screenshot
hold on
connected
let me know if it fails
yep it failed
for flowing-heat
added it to my bookmark
whats the bookmarklet?
please follow the 3 steps on the page
react-scripts: not found
looks like you left out some deps from your frontend's package.jsonearlier .json was -
now-
for frontend
as this error states, you are missing
react-scripts
and likely some other things too, so please correct thatdo i need to run
npm install --package-lock-only
again?
after adding scripts
the railway build log says there are a lot of lock files missingdepedns on how you added them, if manually, yes, if with
npm install
, no
looks like you did it manually, so then you do have to run that lock file commandok
its giving me an error
wait i am delelting the lock file and installing again
using
npm install --package-lock-only
failed again...these are the logs now
.json files are not in sync
wait
did the changes...and its building for last 2 mins
@Brody
okay let me know if it fails again
it did
missing dependencies?
and what else?
you have warning in your build, you have two options, fix the warnings, or set a service variable
CI
to false
arent the dependecies missing?
how to set
process.env.CI = false
?in the service variables
like this?
BUILD COMPLETE
DEPLOY logs 👈
@Brody
cool🔥
now the backend sir @Brody
yep I'm a tab busy will be back soon
yeah sure!
Hey @Brody , its 4 am here. Can this be completed tomorrow?
I can stay up for like..30mins more
if u want
new service, set the root directory, add the repo
that's about it
root directory?
got it
failed while deploying
looks like you are trying to load things from the frontend's
src
folderi cant find 😦
in server.js , I have used a line - "
const ACTIONS = require('./frontend/src/Actions.js');
"
Actions.js
is present in src
of frontend
is this the correct path?you would need it in the backend folder too
the actions.js ?
or the whole
src
the actions file
so..i need to copy paste the file then? in backend?
yes then you would need to update your require path
and then again sync the json lock file?
nope
path would be -
./backend/src/Actions.js
?nope, use relative paths
like? :/
./Actions.js
put the file in /backend
Deployed!
do I have to give it the same domain?
two services cant have the same domain
go ahead and generate a domain
did that
app is not working...socket connection failing...just as before adding the backend service
you need to make sure your frontend is calling the backend domain
and how to do so?
call your backend domain and not the frontends domain
this requires a code change
it says - "Cannot GET /"
on my backend domain
does your backend have anything registered for
/
no
then theres no issue there
does your backend have any routes registered for
/
you mean any registered domains?
or?
i mean routes
i used this in my .env thouugh -
REACT_APP_BACKEND_URL= http://localhost:5000
and this in my server.js-
const PORT = process.env.PORT || 5000;
server.listen(PORT, () => console.log(
Listening on port ${PORT}));
what did you name your backend service
Cypher Code Editor - Backend
then on the frontend service you need to set a service variable
REACT_APP_BACKEND_URL
to https://${{Cypher Code Editor - Backend.RAILWAY_PUBLIC_DOMAIN}}
now...i have to open my frontend domain?
did you add the service variable?
yes
if you click the eye icon on it, does it render properly?
yes it does
are you using
REACT_APP_BACKEND_URL
in your frontend's code?yes
in socket.js
import { io } from 'socket.io-client';
export const initSocket = async () => {
const options = {
'force new connection': true,
reconnectionAttempt: 'Infinity',
timeout: 10000,
transports: ['websocket'],
};
return io(process.env.REACT_APP_BACKEND_URL, options);
};
okay then try your frontend again
in
src
i tried...it was showing socket connection failedwhat url is it trying to connect to
wait...its working now!!!
it was not working a min ago
ah you didnt wait for it to redeploy
no sir i waited
it takes a bit dont worry
its working now !!
thats awsome
but the process was too tough :9
for a beginner, yeah i agree
can i use this same method to deploy any fullstack project?
more or less, but you can also use the method of asking me
😅😂 yeah sure
Thanks a lot for this..it was my first full stack project
no problem, its what im here for
just curious... can i deploy it on other services like (aws,azure) the same way?
or if I haven't restructured the repo at all
those services are vastly different to railway, so probably not, but the project structure you have now is most suitable for the project itself
ohh got it
And do you work for railway?
nope
or just contributing ?
just helping out
amazing
how can i learn things?
about frontend and backend
keep making projects like the one you having now, and keep deploying to railway and you will learn fast
thats all ive done, just make stuff, dive in
ive never followed any coding tutorials or anything like that, dont have the attention span for that, plus theyre boring
and how long will this project run?
it tells me that i am on a free trial plan
if this is your only running project, then you get 5$, so your 5$ could be depleted in about 2 months, but thats just a guess
once you run out of those credits your apps shut down
ohh
may i know why we need it in backend too? And will I know what files are supposed to be in frontend and in backend?
your frontend and backend are using the same types, so that file needed to be in the both folders since we did an isolated monorepo.
when we first started I did not realize that you where sharing types and thought an isolated monorepo would be sufficient but I've since released that it should be a shared monorepo with workspaces, I realized that when I noticed the import actions.js error, but I didn't say anything then because neither of us had the time to get into it and it was only a single file with a hand full of types.
if you'd like help converting to a shared monorepo with workspaces I will offer to do that for you and submit a PR to your repo
Yeah sure. Thank you!
I don't know when I'll be free to do that though but I'll update you here once that I make the pr because it will require changes to your railway services too
@4vinn - heres the pr, ive updated your readme with new deployment instructions
https://github.com/4vinn/cypher-code-editor/pull/1
So i need to again make an empty railway project and deploy it from scratch?
no you dont need to, but only what the instructions tell you to do, but it might be less explaining on my part if you did start from a new project