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.

PANIC: called `Option::unwrap()` on a `None` value in query-engine/core/src/interpreter/query_interpreters/nested_read.rs:231:50

See original GitHub issue

Bug description

Hi, I’m suddenly getting this on our Prisma server:

Thrown with args: {}
Resolver info : { prev: undefined, key: 'me', typename: 'Query' }
Model : User
Error : PrismaClientRustPanicError2 [PrismaClientRustPanicError]:
Invalid `prisma.user.findUnique()` invocation:
  PANIC: called `Option::unwrap()` on a `None` value in query-engine/core/src/interpreter/query_interpreters/nested_read.rs:231:50
This is a non-recoverable error which probably happens when the Prisma Query Engine has a panic.

How to reproduce

  1. Launch your prisma project
  2. Leave it running for ~20 hours
  3. See the above error

Expected behavior

As Douglas Adams wrote, “Dont panic!”

Prisma information

Using paljs and nexus

query { me { id } }

Environment & setup

  • OS: Linux using Docker node:16-buster
  • Database:
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["selectRelationCount", "filterJson", "referentialActions", "nApi"]
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}
  • Node.js version: 16

Prisma Version

"@prisma/client": "2.28.0",
"prisma": "2.28.0",

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:24 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
andrewicarlsoncommented, May 10, 2022

I can reproduce this issue. Please see this repo for a small reproduction. It seems as though this Rust Panic occurs when a relationship is created using a non-unique constraint. Some connectors check for this (SQLite) but others don’t and cause a runtime error (MySQL)

Notes:

  1. When using the SQLite connector an error is thrown in the command line tooling, catching this error before it gets to production. MySQL throws no error and then the Rust engine Panics at runtime.
Error: P1012

error: Error validating: The argument `references` must refer to a unique criteria in the related model `A`. But it is referencing the following fields that are not a unique criteria: custom_id
  -->  schema.prisma:21
  1. This reproduction uses v3.11.0. In >v3.12 an opaque error is thrown in the command line tooling that is difficult to debug.
An error occured while running the seed command:
Error: Command was killed with SIGKILL (Forced termination): ts-node prisma/seed.ts
1reaction
binary64commented, Mar 16, 2022

My hunches are:

  • In our express server, we have a global array of PrismaClients. Each customer has their own mysql database. Plus we have one master mysql which has the list of the customers. So in some resolvers, we even call both the master, and the customer PrismaClient.
  • There is a memory issue where you do a large query that somehow starves or corrupts the arguments for the nested_join.rs function until the node is restarted.
Read more comments on GitHub >

github_iconTop Results From Across the Web

called `Option::unwrap()` on a `None` value in query-engine ...
Hi Prisma Team! My Prisma Client just crashed. It looks like this is a critical bug because after it happens, no more query...
Read more >
Panicked at 'called `Option::unwrap()` on a `None` value ...
Hi! I'm currently porting the Lox language from Crafting Interpreters , but I've been stuck for a while in an annoying bug.
Read more >
libpnet error: thread 'main' panicked at 'called `Option::unwrap ...
It seems that adding tcp_header.set_options() results in a panic. thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', ...
Read more >
stylo: panicked at 'called `Option::unwrap()` on a `None` value'
stylo: panicked at 'called `Option::unwrap()` on a `None` value' ... 30: std::panicking::try::do_call 31: <unknown> Redirecting call to abort() to ...
Read more >
Called `Option::unwrap()` on a `None` value - Editors and IDEs
I get this macro expansion warning with matklad.rust-analyzer v 0.2.776 with VSCode but not with cargo builld. If I take out the a...
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