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.

Segmentation fault crash when using prisma client when using PostgreSQL

See original GitHub issue

Bug description

When trying to use findMany() (or any other method) on a model, prisma client crashes and the following line appears in my log: Segmentation fault (core dumped).

This only happens if I use PostgreSQL as far as I know, this first appeared when I switched to PostgreSQL from mysql.

How to reproduce

  1. Initiate a new prisma project (make sure to use PostgreSQL) and generate the client - no errors there
  2. Write a simple client which fetches some data from the databse
  3. The script crashes and Segmentation fault (core dumped) gets logged in the console

Expected behavior

The script does not crash.

Prisma information

Example schema:

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
    id String @id
    email String?
}

Example test client:

const {PrismaClient} = require('@prisma/client');
const prisma = new PrismaClient({ log: ['query', 'info', 'warn'] })
prisma.user.findMany().then((e) => {
    console.log(e)
})

Environment & setup

  • OS: Pop!_OS (Linux pop-os 5.15.5-76051505-generic #202111250933~1638201579~21.04~09f1aa7-Ubuntu SMP Tue Nov 30 02: x86_64 x86_64 x86_64 GNU/Linux)
  • Database: PostgreSQL v14.1 (Ubuntu 14.1-1.pgdg21.04+1)
  • Node.js version: v17.2.0

Prisma Version

prisma                  : 3.6.0
@prisma/client          : 3.6.0
Current platform        : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine        : migration-engine-cli dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine    : introspection-core dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary           : prisma-fmt dc520b92b1ebb2d28dc3161f9f82e875bd35d727 (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash    : dc520b92b1ebb2d28dc3161f9f82e875bd35d727
Studio                  : 0.440.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:17
  • Comments:50 (20 by maintainers)

github_iconTop GitHub Comments

25reactions
aqrlncommented, Sep 19, 2022

While we are looking for the best way to fix or prevent the underlying problem, the recommended workaround for affected users 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). Depending on your requirements, it might be less suitable for production systems, but this is a good option for those who only encounter the issue on their local machines during development.

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 (at the moment of writing) Node.js 18.6.0 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.

17reactions
sbklcommented, Jan 26, 2022

Add the same issue running on latest node version 17.4.0. Fixed by using the current LTS 16.3.2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node application crashes on prisma request (segmentation ...
Prisma is connecting to my own Postgres database outside of fly.io (it's a supabase postgres instance), not sure if that is relevant at...
Read more >
Segmentation fault on postgresql 13.4, 12.8 with function call ...
Hi,. a recent change in postgresql is causing a segfault when a function is called in filter section, e.g. with a plan like...
Read more >
Troubleshooting database outages and connection issues
Learn about the possible reasons your database might be down or not connected and what you can do to fix it.
Read more >
Bug listing with status RESOLVED with resolution OBSOLETE ...
systemPrefs with at least two files" status:RESOLVED resolution:OBSOLETE severity:normal ... Bug:79320 - "xfwm4 4.2.0 random segfault" status:RESOLVED ...
Read more >
Pulse · prisma/prisma · GitHub
Segmentation fault crash when using prisma client when using PostgreSQL. #10649 commented on Sep 8, 2022 • 2 new comments. Cursor based pagination...
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