Prisma suddenly crashes on today's deploys 10/12/24 despite no changes?

stefanflorea00
PRO

6 months ago

Hi, we have an API service that uses prisma. Yesterday deployed an update, everything is fine. Today, nothing changed infrastructure wise, however, on deploying again, started getting the error message below. Database couldn't connect:

deploy log

prisma:warn Prisma failed to detect the libssl/openssl version to use, and may not work as expected. Defaulting to "openssl-1.1.x".

Please manually install OpenSSL and try installing Prisma again.

I changed to force install the openssl in the dockerfile
Dockerfile was using:

dockerfile

FROM node:20-alpine as builder
...
// added after, worked fine before without these
RUN apk update
RUN apk add --no-cache openssl
...

schema.prisma

generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "linux-musl-openssl-3.0.x", "debian-openssl-3.0.x"]
}

Running locally from the same dockerfile worked ok, on the deployed version gave the error.
Tried to change prisma versions in package.json, but that didn't make any change.
What fixed it was changing from node:20-alpine to node:18-slim
Rolling back to yesterday's deploy (before changing anything in the dockerfile) worked as it should.

I am not that experienced with docker and deploying processes. Maybe could someone explain what could cause the issue?
Could it be some alpine update?
Thank you.

Project ID: 6bd43efc-3425-4163-bbce-f4a714622bd9

Solved

2 Replies

anthowen
PRO

6 months ago

Encountered with the same issue here!


anthowen
PRO

6 months ago

I did nothing with the prisma/dockerfile, but today's deplyment failed


anthowen
PRO

6 months ago

Dockerfile nor Prisma versions are not updated at all, but with the same code, the deployment is failed


anthowen
PRO

6 months ago

I wonder if it is related to any thing on Railway side? @Brody @Chandrika


6 months ago

do not tag the team <#727685388893945877> #5


anthowen
PRO

6 months ago

Sorry, I didn't know about that


6 months ago

so after installing openssl in the Dockerfile is your project working again? that wasn't clear to me


anthowen
PRO

6 months ago

I haven't tried this, but will let you know in a bit


6 months ago

from the snippet above it looks like you have?


anthowen
PRO

6 months ago

Sorry, it isn't my snippet


anthowen
PRO

6 months ago

I'm the second person experiencing this issue


anthowen
PRO

6 months ago

I'm not OP


6 months ago

indeed you are, you are the only one in the comments so my brain thought you where OP


anthowen
PRO

6 months ago

It doesn't work.

Here's the log. Indeed this is related to Prisma, but the main thing is I did not update anything prisma related

prisma:warn Prisma failed to detect the libssl/openssl version to use, and may not work as expected. Defaulting to "openssl-1.1.x".

Please manually install OpenSSL and try installing Prisma again.

This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:

PrismaClientInitializationError: Prisma Client could not locate the Query Engine for runtime "linux-musl".

This happened because Prisma Client was generated for "debian-openssl-3.0.x", but the actual deployment required "linux-musl".

Add "linux-musl" to `binaryTargets` in the "schema.prisma" file and run `prisma generate` after saving it:

generator client {

provider      = "prisma-client-js"

binaryTargets = ["native", "linux-musl-openssl-3.0.x", "linux-musl-arm64-openssl-3.0.x", "linux-musl"]

}

6 months ago

show me your Dockerfile please


anthowen
PRO

6 months ago

Ok, I was wrong. Adding openssl fixes the deployment. I did that not in the production bulid before


anthowen
PRO

6 months ago

But I still wonder what has caused this change


anthowen
PRO

6 months ago

with this, service is working again

1316067258690441500


6 months ago

alpine likely changed something


anthowen
PRO

6 months ago

That's likely, yeah


6 months ago

we dont actually recommend using alpine anyway, it has an inferior network stack compared to debian distros


anthowen
PRO

6 months ago

Alright, make sense. Will consider updating


newarifrh
PRO

6 months ago

u can solve with this code

RUN ln -s /usr/lib/libssl.so.3 /lib/libssl.so.3

newarifrh

u can solve with this codeRUN ln -s /usr/lib/libssl.so.3 /lib/libssl.so.3

newarifrh
PRO

6 months ago

prisma failed to find libssl.so, due to change of location of libssl.so on alpine


stefanflorea00
PRO

6 months ago

Ok, yes, as you said, adding the openssl in dockerfile fixes it locally, but not on the production
What fixed it for me on production was changing node:20-alpine to node:18-slim


stefanflorea00
PRO

6 months ago


stefanflorea00
PRO

6 months ago

dockerfile

# Use the Node.js base image (slim version for smaller size)
FROM node:18-slim as builder
# Create app directory
WORKDIR /usr/src/app
# Copy package.json and package-lock.json
COPY package*.json ./
RUN apt-get update
RUN apt-get install -y openssl
# Install production dependencies only
RUN npm install 
# Copy the rest of the application code
COPY . .
RUN npm run build
# Generate Prisma client
RUN npx prisma generate
# --- Production image ---
FROM node:18-slim
RUN apt-get update
RUN apt-get install -y openssl
# Create app directory
WORKDIR /usr/src/app
# Copy only the necessary files from the builder stage
COPY --from=builder /usr/src/app /usr/src/app
ENV NODE_ENV=production
# Run Prisma migrations before starting the application
CMD ["sh", "-c", "npx prisma migrate deploy && node dist/index.js"]

stefanflorea00
PRO

6 months ago

Not sure if it's ok, as I said, not that experienced with docker


6 months ago

!s


Status changed to Solved brody 6 months ago


Prisma suddenly crashes on today's deploys 10/12/24 despite no changes? - Railway Help Station