R
Railway12mo ago
4vinn

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
Percy
Percy12mo ago
Project ID: N/A
Brody
Brody12mo ago
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
4vinn
4vinnOP12mo ago
I made a realtime code editor using websocket and nodejs
Brody
Brody12mo ago
is it possible its trying to use more than 512mb of memory? whats your tech stack?
4vinn
4vinnOP12mo ago
react , node
Brody
Brody12mo ago
create react app?
4vinn
4vinnOP12mo ago
yes
Brody
Brody12mo ago
is the backend a seprate railway service?
4vinn
4vinnOP12mo ago
no
Brody
Brody12mo ago
an express api thats also serving the frontend?
4vinn
4vinnOP12mo ago
yes sir
Brody
Brody12mo ago
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
4vinn
4vinnOP12mo ago
ok sure I am quite new! I m sorry
Brody
Brody12mo ago
no worries, we will take this one step at a time and as we go it will all make sense, trust the process
4vinn
4vinnOP12mo ago
Should i share my repo link?
Brody
Brody12mo ago
yes please and to start us off, a screenshot of your railway project just so i know whats up
4vinn
4vinnOP12mo ago
GitHub
GitHub - 4vinn/cypher-code-editor
Contribute to 4vinn/cypher-code-editor development by creating an account on GitHub.
4vinn
4vinnOP12mo ago
ss of my logs?
Brody
Brody12mo ago
of the railway project, aka your browsers viewport
4vinn
4vinnOP12mo ago
No description
Brody
Brody12mo ago
go ahead and remove the repo from that service from within its settings page
4vinn
4vinnOP12mo ago
done
Brody
Brody12mo ago
another screenshot please
4vinn
4vinnOP12mo ago
No description
Brody
Brody12mo ago
you removed the service itself close enough
4vinn
4vinnOP12mo ago
ohh should i add the service again
Brody
Brody12mo ago
nah we will do it later
4vinn
4vinnOP12mo ago
what should I do?
Brody
Brody12mo ago
for now you need to restructure your repo into a monorepo, that would look like this
.
├── .gitignore
├── README
├── frontend/
│ ├── public
│ ├── src
│ ├── package.json
│ └── package-lock.json
└── backend/
├── server.js
├── package.json
└── package-lock.json
.
├── .gitignore
├── README
├── frontend/
│ ├── public
│ ├── src
│ ├── package.json
│ └── package-lock.json
└── backend/
├── server.js
├── package.json
└── package-lock.json
4vinn
4vinnOP12mo ago
ok just a sec
Brody
Brody12mo ago
no worries, take your time
4vinn
4vinnOP12mo ago
done @Brody
Brody
Brody12mo ago
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
4vinn
4vinnOP12mo ago
so we will serve frontend and backend differently Separately*
Brody
Brody12mo ago
correct, they will be separate railway services
4vinn
4vinnOP12mo ago
@Brody can you please check now?
Brody
Brody12mo ago
your lock files arent in sync run npm install --package-lock-only in both folders
4vinn
4vinnOP12mo ago
check now
Brody
Brody12mo ago
last change was 9 minutes ago
4vinn
4vinnOP12mo ago
it gave me "1 high severity vulnerability" in frontned
Brody
Brody12mo ago
youll have that sometimes
4vinn
4vinnOP12mo ago
check now sire
Brody
Brody12mo ago
https://github.com/brody192/create-react-app-starter copy the nixpacks.toml and Caddyfile from this repo into your frontend folder
4vinn
4vinnOP12mo ago
ok...may i know what are these?
Brody
Brody12mo ago
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
4vinn
4vinnOP12mo ago
i added the files
Brody
Brody12mo ago
remove the .txt extension please
4vinn
4vinnOP12mo ago
didn't get the gist of it, but ok 🙂
Brody
Brody12mo ago
trust the process, remember 😉 ive done this a hundred times
4vinn
4vinnOP12mo ago
done
Brody
Brody12mo ago
okay i think its time to deploy the frontend
4vinn
4vinnOP12mo ago
i mean I dont doubt you, its just a lot for me to understand...i just got in this field 😦
Brody
Brody12mo ago
add a new empty service to your project
4vinn
4vinnOP12mo ago
ok
Brody
Brody12mo ago
for the nexts steps can you send a screenshot each time? just so i know things are going smoothly
4vinn
4vinnOP12mo ago
ok
4vinn
4vinnOP12mo ago
No description
4vinn
4vinnOP12mo ago
i added an empty service is it ok?
Brody
Brody12mo ago
in its settings, set the root dir to /frontend
4vinn
4vinnOP12mo ago
done
Brody
Brody12mo ago
give it an good name like Cypher Code Editor - Frontend and generate yourself a domain
4vinn
4vinnOP12mo ago
done
4vinn
4vinnOP12mo ago
No description
Brody
Brody12mo ago
add your repo to the service
4vinn
4vinnOP12mo ago
in this service?
Brody
Brody12mo ago
yep
4vinn
4vinnOP12mo ago
how? 😅
Brody
Brody12mo ago
look through the settings, you will see an option to add your repo
4vinn
4vinnOP12mo ago
connect repo option?
Brody
Brody12mo ago
yep
4vinn
4vinnOP12mo ago
done but nothing happened
Brody
Brody12mo ago
screenshot
4vinn
4vinnOP12mo ago
No description
4vinn
4vinnOP12mo ago
hold on
4vinn
4vinnOP12mo ago
connected
No description
Brody
Brody12mo ago
let me know if it fails
4vinn
4vinnOP12mo ago
yep it failed for flowing-heat
4vinn
4vinnOP12mo ago
added it to my bookmark whats the bookmarklet?
Brody
Brody12mo ago
please follow the 3 steps on the page
Brody
Brody12mo ago
react-scripts: not found looks like you left out some deps from your frontend's package.json
4vinn
4vinnOP12mo ago
earlier .json was -
{
"name": "realtime-editor",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.5.0",
"codemirror": "^5.65.2",
"express": "^4.17.3",
"react": "^17.0.2",
"react-avatar": "^4.0.0",
"react-dom": "^17.0.2",
"react-hot-toast": "^2.2.0",
"react-router-dom": "^6.21.0",
"react-scripts": "5.0.0",
"socket.io": "^4.4.1",
"socket.io-client": "^4.4.1",
"uuid": "^8.3.2",
"web-vitals": "^2.1.4"
},
"scripts": {
"start:front": "react-scripts start",
"start": "npm run build && npm run server:prod",
"build": "react-scripts build",
"server:dev": "nodemon server.js",
"server:prod": "node server.js",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"nodemon": "^2.0.15"
}
}
{
"name": "realtime-editor",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.5.0",
"codemirror": "^5.65.2",
"express": "^4.17.3",
"react": "^17.0.2",
"react-avatar": "^4.0.0",
"react-dom": "^17.0.2",
"react-hot-toast": "^2.2.0",
"react-router-dom": "^6.21.0",
"react-scripts": "5.0.0",
"socket.io": "^4.4.1",
"socket.io-client": "^4.4.1",
"uuid": "^8.3.2",
"web-vitals": "^2.1.4"
},
"scripts": {
"start:front": "react-scripts start",
"start": "npm run build && npm run server:prod",
"build": "react-scripts build",
"server:dev": "nodemon server.js",
"server:prod": "node server.js",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"nodemon": "^2.0.15"
}
}
now-
{
"name": "realtime-editor-frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.5.0",
"codemirror": "^5.65.2",
"react": "^17.0.2",
"react-avatar": "^4.0.0",
"react-dom": "^17.0.2",
"react-hot-toast": "^2.2.0",
"react-router-dom": "^6.21.0",
"socket.io-client": "^4.4.1",
"uuid": "^8.3.2",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
{
"name": "realtime-editor-frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.5.0",
"codemirror": "^5.65.2",
"react": "^17.0.2",
"react-avatar": "^4.0.0",
"react-dom": "^17.0.2",
"react-hot-toast": "^2.2.0",
"react-router-dom": "^6.21.0",
"socket.io-client": "^4.4.1",
"uuid": "^8.3.2",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
for frontend
Brody
Brody12mo ago
as this error states, you are missing react-scripts and likely some other things too, so please correct that
4vinn
4vinnOP12mo ago
do 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 missing
4vinn
4vinnOP12mo ago
No description
Brody
Brody12mo ago
depedns 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 command
4vinn
4vinnOP12mo ago
ok
4vinn
4vinnOP12mo ago
its giving me an error
No description
4vinn
4vinnOP12mo ago
wait i am delelting the lock file and installing again using npm install --package-lock-only
4vinn
4vinnOP12mo ago
failed again...these are the logs now
4vinn
4vinnOP12mo ago
.json files are not in sync wait did the changes...and its building for last 2 mins @Brody
Brody
Brody12mo ago
okay let me know if it fails again
4vinn
4vinnOP12mo ago
4vinn
4vinnOP12mo ago
missing dependencies? and what else?
Brody
Brody12mo ago
you have warning in your build, you have two options, fix the warnings, or set a service variable CI to false
4vinn
4vinnOP12mo ago
arent the dependecies missing? how to set process.env.CI = false?
Brody
Brody12mo ago
in the service variables
4vinn
4vinnOP12mo ago
like this?
No description
4vinn
4vinnOP12mo ago
BUILD COMPLETE
4vinn
4vinnOP12mo ago
DEPLOY logs 👈
4vinn
4vinnOP12mo ago
@Brody
4vinn
4vinnOP12mo ago
No description
4vinn
4vinnOP12mo ago
cool🔥
No description
4vinn
4vinnOP12mo ago
now the backend sir @Brody
Brody
Brody12mo ago
yep I'm a tab busy will be back soon
4vinn
4vinnOP12mo ago
yeah sure! Hey @Brody , its 4 am here. Can this be completed tomorrow? I can stay up for like..30mins more if u want
Brody
Brody12mo ago
new service, set the root directory, add the repo that's about it
4vinn
4vinnOP12mo ago
root directory? got it failed while deploying
Brody
Brody12mo ago
looks like you are trying to load things from the frontend's src folder
4vinn
4vinnOP12mo ago
i cant find 😦
.
├── .gitignore
├── README
├── frontend/
│ ├── public
│ ├── src
│ ├── package.json
│ └── package-lock.json
└── backend/
├── server.js
├── package.json
└── package-lock.json
.
├── .gitignore
├── README
├── frontend/
│ ├── public
│ ├── src
│ ├── package.json
│ └── package-lock.json
└── backend/
├── server.js
├── package.json
└── package-lock.json
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?
Brody
Brody12mo ago
you would need it in the backend folder too
4vinn
4vinnOP12mo ago
the actions.js ? or the whole src
Brody
Brody12mo ago
the actions file
4vinn
4vinnOP12mo ago
so..i need to copy paste the file then? in backend?
Brody
Brody12mo ago
yes then you would need to update your require path
4vinn
4vinnOP12mo ago
and then again sync the json lock file?
Brody
Brody12mo ago
nope
4vinn
4vinnOP12mo ago
path would be - ./backend/src/Actions.js ?
Brody
Brody12mo ago
nope, use relative paths
4vinn
4vinnOP12mo ago
like? :/
Brody
Brody12mo ago
./Actions.js put the file in /backend
4vinn
4vinnOP12mo ago
Deployed! do I have to give it the same domain?
Brody
Brody12mo ago
two services cant have the same domain go ahead and generate a domain
4vinn
4vinnOP12mo ago
did that app is not working...socket connection failing...just as before adding the backend service
Brody
Brody12mo ago
you need to make sure your frontend is calling the backend domain
4vinn
4vinnOP12mo ago
and how to do so?
Brody
Brody12mo ago
call your backend domain and not the frontends domain this requires a code change
4vinn
4vinnOP12mo ago
it says - "Cannot GET /" on my backend domain
Brody
Brody12mo ago
does your backend have anything registered for /
4vinn
4vinnOP12mo ago
no
Brody
Brody12mo ago
then theres no issue there
4vinn
4vinnOP12mo ago
No description
Brody
Brody12mo ago
does your backend have any routes registered for /
4vinn
4vinnOP12mo ago
you mean any registered domains? or?
Brody
Brody12mo ago
i mean routes
4vinn
4vinnOP12mo ago
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}));
Brody
Brody12mo ago
what did you name your backend service
4vinn
4vinnOP12mo ago
Cypher Code Editor - Backend
Brody
Brody12mo ago
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}}
4vinn
4vinnOP12mo ago
now...i have to open my frontend domain?
Brody
Brody12mo ago
did you add the service variable?
4vinn
4vinnOP12mo ago
yes
Brody
Brody12mo ago
if you click the eye icon on it, does it render properly?
4vinn
4vinnOP12mo ago
yes it does
Brody
Brody12mo ago
are you using REACT_APP_BACKEND_URL in your frontend's code?
4vinn
4vinnOP12mo ago
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); };
Brody
Brody12mo ago
okay then try your frontend again
4vinn
4vinnOP12mo ago
in src i tried...it was showing socket connection failed
Brody
Brody12mo ago
what url is it trying to connect to
4vinn
4vinnOP12mo ago
wait...its working now!!! it was not working a min ago
Brody
Brody12mo ago
ah you didnt wait for it to redeploy
4vinn
4vinnOP12mo ago
no sir i waited
Brody
Brody12mo ago
it takes a bit dont worry
4vinn
4vinnOP12mo ago
its working now !!
Brody
Brody12mo ago
thats awsome
4vinn
4vinnOP12mo ago
but the process was too tough :9
Brody
Brody12mo ago
for a beginner, yeah i agree
4vinn
4vinnOP12mo ago
can i use this same method to deploy any fullstack project?
Brody
Brody12mo ago
more or less, but you can also use the method of asking me
4vinn
4vinnOP12mo ago
😅😂 yeah sure Thanks a lot for this..it was my first full stack project
Brody
Brody12mo ago
no problem, its what im here for
4vinn
4vinnOP12mo ago
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
Brody
Brody12mo ago
those services are vastly different to railway, so probably not, but the project structure you have now is most suitable for the project itself
4vinn
4vinnOP12mo ago
ohh got it And do you work for railway?
Brody
Brody12mo ago
nope
4vinn
4vinnOP12mo ago
or just contributing ?
Brody
Brody12mo ago
just helping out
4vinn
4vinnOP12mo ago
amazing how can i learn things? about frontend and backend
Brody
Brody12mo ago
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
4vinn
4vinnOP12mo ago
and how long will this project run? it tells me that i am on a free trial plan
Brody
Brody12mo ago
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
4vinn
4vinnOP12mo ago
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?
Brody
Brody12mo ago
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
4vinn
4vinnOP12mo ago
Yeah sure. Thank you!
Brody
Brody12mo ago
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
4vinn
4vinnOP12mo ago
So i need to again make an empty railway project and deploy it from scratch?
Brody
Brody12mo ago
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
Want results from more Discord servers?
Add your server