3 months ago
I have read the texts in the help section, but I am quite new to railway and I don't understand anything.
0 Replies
a worker said to add 3 seconds in the forum, I added it, but the same problem still exists
3 months 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)
3 months 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;
3 months ago
can you show me this npm run migrate command?
3 months ago
what does it reflect to in your package.json
3 months ago
its blue, they have not yet saved the changes
3 months ago
true
3 months ago
btw I thought we didn't need to wait for the private network anymore
3 months ago
I thought that was fixed
3 months ago
🤔
3 months ago
we dont, they likely read a very old thread
3 months 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"
},
3 months ago
no.
3 months ago
try the public db url, I wanna see if it connects
3 months ago
link to project please
brody I'm not going to lie I'm used to doing everything with vercel with one click
3 months 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.
3 months ago
i'm wondering if it's because of his app being CSR
3 months ago
that is the public TCP proxy, please go back to using the private url for the database connection
3 months ago
yeah but CSR apps still won't talk to the database from the user's browser
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/nodemodules/.prisma/client/runtime/library.js:124:7759) at zn.handleAndLogRequestError (/app/nodemodules/.prisma/client/runtime/library.js:124:6784)
at zn.request (/app/nodemodules/.prisma/client/runtime/library.js:124:6491) at async l (/app/nodemodules/.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.
3 months 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.
3 months 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_PHASE
env var
frankly, the project is not mine, I was just helping someone or he will try to host the next.js project from cpanel
3 months ago
The easier approach is to switch to SSR, that's a one liner depending on the project
3 months 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>
2 months ago
!s
Status changed to Solved medim • 2 months ago