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

stefanflorea00PRO

5 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

anthowenPRO

5 months ago

Encountered with the same issue here!


anthowenPRO

5 months ago

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


anthowenPRO

5 months ago

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


anthowenPRO

5 months ago

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


5 months ago

do not tag the team <#727685388893945877> #5


anthowenPRO

5 months ago

Sorry, I didn't know about that


5 months ago

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


anthowenPRO

5 months ago

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


5 months ago

from the snippet above it looks like you have?


anthowenPRO

5 months ago

Sorry, it isn't my snippet


anthowenPRO

5 months ago

I'm the second person experiencing this issue


anthowenPRO

5 months ago

I'm not OP


5 months ago

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


anthowenPRO

5 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"]

}

5 months ago

show me your Dockerfile please


anthowenPRO

5 months ago

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


anthowenPRO

5 months ago

But I still wonder what has caused this change


anthowenPRO

5 months ago

with this, service is working again

1316067258690441500


5 months ago

alpine likely changed something


anthowenPRO

5 months ago

That's likely, yeah


5 months ago

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


anthowenPRO

5 months ago

Alright, make sense. Will consider updating


newarifrhPRO

5 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

newarifrhPRO

5 months ago

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


stefanflorea00PRO

5 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


stefanflorea00PRO

5 months ago


stefanflorea00PRO

5 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"]

stefanflorea00PRO

5 months ago

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


5 months ago

!s


Status changed to Solved brody 5 months ago