a year ago
I have read the texts in the help section, but I am quite new to railway and I don't understand anything.
54 Replies
a worker said to add 3 seconds in the forum, I added it, but the same problem still exists
a year ago
how exactly are you adding these 3 seconds?
so I didn't understand and chatgpt added something 3 seconds into lib/prisma.ts (and I guess it didn't work)
a year ago
can you undo what chatgpt suggested and show me your start command (or are you doing the migration in the pre-deploy command?)
import { PrismaClient } from '@prisma/client';
declare global {
// eslint-disable-next-line no-var
var prisma: PrismaClient | undefined;
}
let prisma: PrismaClient;
const connectWithRetry = async (client: PrismaClient, retries = 5, delay = 3000) => {
for (let i = 0; i < retries; i++) {
try {
await client.$connect();
console.log(':white_check_mark: Prisma: connected');
return;
} catch (error) {
console.error(`❌ error (x${i + 1}):`, error);
if (i < retries - 1) {
await new Promise((res) => setTimeout(res, delay));
} else {
throw error;
}
}
}
};
// Singleton ve retry birleştirildi
if (!globalThis.prisma) {
const client = new PrismaClient();
await connectWithRetry(client);
globalThis.prisma = client;
}
prisma = globalThis.prisma;
export default prisma;a year ago
can you show me this npm run migrate command?
a year ago
what does it reflect to in your package.json
a year ago
its blue, they have not yet saved the changes
a year ago
true
a year ago
btw I thought we didn't need to wait for the private network anymore
a year ago
I thought that was fixed
a year ago
🤔
a year ago
we dont, they likely read a very old thread
a year ago
yep
"name": "qrmenu",
"version": "0.1.1",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build --no-lint",
"start": "next start",
"postinstall": "npx prisma generate && npx prisma db push",
"lint": "next lint"
},
"prisma": {
"seed": "ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts"
},
a year ago
no.
a year ago
try the public db url, I wanna see if it connects
a year ago
link to project please
brody I'm not going to lie I'm used to doing everything with vercel with one click
a year ago
you are trying to reach the database over an http domain, let's go back to the private url.
unfortunately Railway the platform cannot help with incorrect implementation.
a year ago
i'm wondering if it's because of his app being CSR
a year ago
that is the public TCP proxy, please go back to using the private url for the database connection
a year ago
yeah but CSR apps still won't talk to the database from the user's browser
this? postgresql://postgres:x@postgres.railway.internal:5432/railway
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
PrismaClientInitializationError:
Invalid prisma.appSettings.findUnique() invocation:
Can't reach database server at postgres.railway.internal:5432
Please make sure your database server is running at postgres.railway.internal:5432.
at zn.handleRequestError (/app/node_modules/.prisma/client/runtime/library.js:124:7759)
at zn.handleAndLogRequestError (/app/node_modules/.prisma/client/runtime/library.js:124:6784)
at zn.request (/app/node_modules/.prisma/client/runtime/library.js:124:6491)
at async l (/app/node_modules/.prisma/client/runtime/library.js:133:9778)
at async l (/app/.next/server/app/page.js:1:1253)
Export encountered an error on /page: /, exiting the build.
a year ago
the private network is not available during build, you will need to switch to SSR during runtime instead of SSG during build, or temporarily switch to the public network just for build time.
I'll let the community help with the implementation details.
a year ago
You got two approaches to this issue:
- Switching to SSR (easier one but depends on your nextjs project)
- Conditionally switch between private (on runtime) and public (on build) db url, you can identify in which step nextjs is with the
NEXT_PHASEenv var
frankly, the project is not mine, I was just helping someone or he will try to host the next.js project from cpanel
a year ago
The easier approach is to switch to SSR, that's a one liner depending on the project
a year ago
No worries, sorry I couldn't be more helpful! this is more of a code issue and I have some skill issues with nextjs <:kekw:788259314607325204>
a year ago
!s
Status changed to Solved medim • about 1 year ago
