question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`libraryEngine` silently fails to start (crash in container on Compute Engine)

See original GitHub issue

Bug 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:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
aqrlncommented, Oct 13, 2022

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:

  • either by downgrading Node.js to 16.x,
  • or by upgrading the operating system (or Docker image) to use OpenSSL 3 (for example, by using Ubuntu 22.04 instead of Debian 11).

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 repository community: 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.

0reactions
bryceAebicommented, Oct 10, 2022

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.

instance-2-test-for-prisma:/usr/src/app# DEBUG=* npx tsx src/scripts/add-missing-routines-to-users.ts 
  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 +101ms
  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 +1ms
  prisma:client  cwd /usr/src/app/prisma +0ms
  prisma:client  clientVersion 4.4.0 +1ms
  prisma:client  clientEngineType library +0ms
  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: +112ms
  prisma:client  prisma.user.findMany(undefined) +2ms
  prisma:client  Generated request: +0ms
  prisma:client  query {
  findManyUser {
   ... omitted ...
  }
}
 +1ms
  prisma:client:libraryEngine  sending request, this.libraryStarted: false +115ms
  prisma:client:libraryEngine  library starting +0ms
  prisma:client:libraryEngine  library started +30ms
  prisma:client  Prisma Client call: +39ms
  prisma:client  prisma.routineTracker.findFirst({
  where: {


   ... Query logs omitted ...

  prisma:client:libraryEngine  sending request, this.libraryStarted: true +3ms
  prisma:client:libraryEngine  library stopping +9ms
  prisma:client:libraryEngine  library stopped +1ms
  prisma:client:libraryEngine:exitHooks  exit event received: beforeExit +0ms
  prisma:client:libraryEngine:exitHooks  exit event received: exit +0ms
Read more comments on GitHub >

github_iconTop Results From Across the Web

Segmentation fault crash when using prisma client ... - GitHub
I used a fresh VM (Ubuntu 20.04 LTS) on Google Compute Engine. ... libraryEngine silently fails to start (crash in container on Compute ......
Read more >
Check a crashed app for errors by using Error Reporting
Open a Cloud Shell for your Cloud project. While it starts, the message Connecting is displayed. Open Cloud Shell. Simulate an error.
Read more >
Why is Google Compute Engine not running my container?
There, I see this error in the logs: "Error: Failed to start container: invalid reference format". This is for the demo, for which...
Read more >
SAS Hot Fixes - Fix List for E9H004 on Solaris (64-bit)
General Issues, SN-013311, MYSQL engine fails when trying to process more than 4000 inserts or updates via SQL Pass-through, SP1 (D9YQ02).
Read more >
Cloud Run container crashing - Google Groups
It seems to be pretty random. If I try and create a new revision, it sometimes restarts successfully, but other times the container...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found