`libraryEngine` silently fails to start (crash in container on Compute Engine)
See original GitHub issueBug description
I have a Docker container running on Compute Engine. I can confirm with psql
that my db connection string is correct. When I run a typscript script, the script exits with no output. With console.log statements, I can see that the script ceases execution silently at my first Prisma query. I’ve also tried running Prisma queries manually via tsx
but running a query causes tsx
to immediately exit with no error.
I have tried deleting and reinstalling node modules and I have tried rerunning prisma generate
, but to no avail.
The script works in the same docker container on my M1 Mac. In the Debug info I notice the following in the Cloud Engine container:
prisma:client:libraryEngine:loader Searching for Query Engine Library in /usr/src/app/node_modules/.prisma/client +0ms
prisma:client:libraryEngine:loader loadEngine using /usr/src/app/node_modules/.prisma/client/libquery_engine-debian-openssl-1.1.x.so.node +1ms
prisma:client:libraryEngine library starting +0ms
Note that in the debug output above, the library does not start. I see the following on my M1 mac
prisma:client:libraryEngine:loader Searching for Query Engine Library in /usr/src/app/node_modules/.prisma/client +0ms
prisma:client:libraryEngine:loader loadEngine using /usr/src/app/node_modules/.prisma/client/libquery_engine-linux-arm64-openssl-1.1.x.so.node
prisma:client:libraryEngine library starting +0ms
prisma:client:libraryEngine library started +12ms
I’m using the standard “Container Optimized OS” that Google pre-selects when passing a VM a docker image during setup.
How to reproduce
/**
* Command I run: `npx tsx src/scripts/reset-progress-for-user.ts`
* /
/**
* Prisma debug output
*/
DEBUG=* npx tsx src/scripts/reset-progress-for-user.ts aouoa aoeu
agentkeepalive sock[0#registry.npmjs.org:443::::::::true:::::::::::::] create, timeout 300001ms +0ms
agentkeepalive sock[0#registry.npmjs.org:443::::::::true:::::::::::::](requests: 1, finished: 1) free +189ms
prisma:tryLoadEnv Environment variables loaded from /usr/src/app/.env +0ms
prisma:tryLoadEnv Environment variables loaded from /usr/src/app/.env +2s
prisma:client dirname /usr/src/app/node_modules/.prisma/client +0ms
prisma:client relativePath ../../../prisma +0ms
prisma:client cwd /usr/src/app/prisma +1ms
prisma:client clientVersion 4.2.1 +0ms
prisma:client clientEngineType library +1ms
prisma:client:libraryEngine internalSetup +0ms
prisma:client:libraryEngine:loader Searching for Query Engine Library in /usr/src/app/node_modules/.prisma/client +0ms
prisma:client:libraryEngine:loader loadEngine using /usr/src/app/node_modules/.prisma/client/libquery_engine-debian-openssl-1.1.x.so.node +1ms
prisma:client Prisma Client call: +460ms
prisma:client prisma.user.findUnique({
where: {
id: 'aouoa'
}
}) +2ms
prisma:client Generated request: +1ms
prisma:client query {
findUniqueUser(where: {
id: "aouoa"
}) {
... omitted ...
}
}
+0ms
prisma:client:libraryEngine sending request, this.libraryStarted: false +464ms
prisma:client:libraryEngine library starting +1ms
Expected behavior
I would expect the script to execute successfully.
Prisma information
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
... omitted ...
@@map("users")
}
/**
* .ts script
*/
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
const main = async () => {
const users = await prisma.user.findMany()
console.log("USERS QUERY COMPLETED") // <= Code never executes
}
main()
.then(async () => {
await prisma.$disconnect()
})
.catch(async (e) => {
console.error(e)
await prisma.$disconnect()
process.exit(1)
})
Environment & setup
- OS: debian 11.5
- Database: Postgresql via Cloud SQL
- Node.js version: v18.9.1
Prisma Version
4.2.1. Same error after upgrading to 4.4.0
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Thank you for the report and for checking things @bryceAebi. This looks like the same issue as https://github.com/prisma/prisma/issues/10649 and other linked issues, so I’m going to go ahead and close this issue in favor of it so it’s easier to keep track of everything.
The reason why the same container with the same database is not crashing for you locally is because the issue only happens on x86_64 CPUs, but not on ARM.
While we are looking for the best way to fix or prevent the underlying problem, the recommended workaround is to make sure that the versions of OpenSSL used by Node.js and the system OpenSSL match:
If your distribution provides a build of Node.js 18 with OpenSSL 1.1.1, you can use that instead of the upstream Node.js build that vendors OpenSSL 3. This is the case on Alpine, where you can install
nodejs-current
from repositorycommunity
: it provides Node.js 18 linked with OpenSSL 1.1.1q, and the issue is not reproducible when using it.Alternatively, if you can’t do any of that and you need to stay with the upstream build of Node.js 18 on a system with OpenSSL 1.1.x, you can switch to the binary engine in Prisma.
Ok, I tried bulding with the node-16-slim image and the scripts are working as expected. Here is the debug output for what it’s worth.
By the way, I should have mentioned in my initial message that Prisma is working fine with my initial configuration on Google Cloud Run through my server (NestJS). It’s just Compute Engine where I’m running into this issue.