R
Railway13mo ago
Mustafa

why I am facing weird javascript errors on railway servers ?

I am facing weird JS errors only on railway servers ?? it works on production locally, and in other cloud providers. I tried different node versions but still the same issue! seems you're building apps and run it in different ways !! that won't make our app works as expected!
20 Replies
Percy
Percy13mo ago
Project ID: N/A
Fragly
Fragly13mo ago
What weird javascript errors are you seeing?
Mustafa
Mustafa13mo ago
e.g iam importing a js function and trying to use it like auth.check(params) I got undefing auth ?? currently i have connected with heroky, and it works as expected I think the issue may be in building or how you're start the app
Fragly
Fragly13mo ago
railway doesn't run code differently from any other hosting services as far as I'm aware, what does that function do?
Mustafa
Mustafa13mo ago
setIsLoading(true)
const res = await authApis?.employeeLogin?.({ mobile, password, countryCode: "+966" })
setIsLoading(false)
setIsLoading(true)
const res = await authApis?.employeeLogin?.({ mobile, password, countryCode: "+966" })
setIsLoading(false)
it throws this error
Uncaught (in promise) TypeError: Cannot destructure property 'message' of 'c' as it is undefined.
at onSubmit
Uncaught (in promise) TypeError: Cannot destructure property 'message' of 'c' as it is undefined.
at onSubmit
runing localy in prod works as expected works also at heroku with the same code
Brody
Brody13mo ago
actually a lot of other hosting providers do a fair amount of monkey patching to get code to run, railway by contrast runs your code as is, so the best you can do is make sure railway runs your code with the same software you run locally, but beyond that it's a code issue
Mustafa
Mustafa13mo ago
it works locally without any issues so i assume the code has no issues both in dev and in production
Brody
Brody13mo ago
unfortunately that does not mean it's not a code issue seen this a million times, it's the "works on my machine" meme
Mustafa
Mustafa13mo ago
thanks for your help
Brody
Brody13mo ago
what node version is railway using, and what version are you using locally just trying to lighten up the mood
Mustafa
Mustafa13mo ago
same node version 20
Brody
Brody13mo ago
okay same node versions that's good, this is pointing to a code issue now, as previously mentioned railway runs your code as is
Mustafa
Mustafa13mo ago
I will try again Now this works
import { authApis } from "../../services/apis/auth/index";
import { authApis } from "../../services/apis/auth/index";
But this Not
import { authApis } from "src/services/apis/auth/index";
import { authApis } from "src/services/apis/auth/index";
Brody
Brody13mo ago
import paths are funky with js
Mustafa
Mustafa13mo ago
It's handled by tsconfig and should works in all envs
Brody
Brody13mo ago
thats ts for you
Mustafa
Mustafa13mo ago
any thing can help that from your side ?
Brody
Brody13mo ago
this isnt an issue with railway? (i also dont work for railway)
Mustafa
Mustafa13mo ago
okay, thanks for your help appreciated
Want results from more Discord servers?
Add your server