Queue, prisma and postgres
lludol
HOBBYOP

2 years ago

Hello,

I have a classic rest API with Fastify (node.js) that is connected to two databases:

Both use Prisma to connect to the database.

My problem is that the second instance has some cron job that are executed for example every day at 6am but sometimes they can't finish their job because there is this error:
PrismaClientKnownRequestError

Invalid prisma.queueJob.count() invocation:
Can't reach database server at monorail.proxy.rlwy.net:30404
Please make sure your database server is running at monorail.proxy.rlwy.net:30404.

To handle the prisma connection, I instanciate on both instances the prisma client through a Fastify plugin that will save the prisma instance to share it with either the routes or the jobs.

Is there something I need to configure on Railway?
I already have disabled the sleeping instance feature.

Do I need to switch and use for example a queue library that use redis for example?
Is it because of the "serverless" state of railway that the connection is terminated?

2 Replies

lucasgarcia98
HOBBY

2 years ago

do you use the project in the same context? the app with fastify, and the instance from postgres


lludol
HOBBYOP

2 years ago

@Garcia Yes like this

1278707945433207000


Loading...