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\response_ir\internal.rs:334:86

See original GitHub issue

Hi Prisma Team! My Prisma Client just crashed. This is the report:

Versions

Name Version
Node v12.22.4
OS windows
Prisma Client 3.0.2
Query Engine 0.1.0
Database mongodb

Logs

ient:libraryEngine internalSetup
prisma:client:libraryEngine Search for Query Engine Library in D:\Deploy\AflexGait-New\aflexgait-api\node_modules\.prisma\client
prisma:client:libraryEngine loadEngine using D:\Deploy\AflexGait-New\aflexgait-api\node_modules\.prisma\client\query_engine-windows.dll.node
prisma:client:libraryEngine library starting
prisma:client:libraryEngine library started
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine requestBatch
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine requestBatch
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine requestBatch
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine requestBatch
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine requestBatch
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine requestBatch
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine requestBatch
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine requestBatch
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine requestBatch
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine requestBatch
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine requestBatch
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine requestBatch
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true
prisma:client:libraryEngine sending request, this.libraryStarted: true

Server Snippet

import "reflect-metadata";
import { buildSchema } from "type-graphql";
import { ApolloServer } from "apollo-server";
import { PrismaClient } from "@prisma/client";

import { resolvers } from "./generated/type-graphql";

interface Context {
  prisma: PrismaClient;
}

async function main() {
  const schema = await buildSchema({
    resolvers,
    validate: false,
  });

  const prisma = new PrismaClient();
  await prisma.$connect();

  const server = new ApolloServer({
    schema,
    context: (): Context => ({ prisma }),
  });
  const { port } = await server.listen(6001);
  console.log(`GraphQL is listening on http://localhost:${port} !`);
}

main().catch(console.error);

Schema

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

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

generator client {
  provider = "prisma-client-js"
  previewFeatures = ["mongoDb"]
}

generator typegraphql {
  provider = "typegraphql-prisma"
  output   = "../src/generated/type-graphql"
  emitTranspiledCode = false
  simpleResolvers = true
}

enum Angle {
  LEFT
  RIGHT 
  CENTER
}

model Patient {
  id String @id @default(dbgenerated()) @map("_id") @db.ObjectId 
  clinicID String @unique() 
  firstName String
  lastName String
  email String
  phone String
  address String
  dob DateTime 
  registerdAt DateTime @default(now())
  lastVist DateTime ?
  gender String
  height Int
  weight Int
  image String ?
  createdAt DateTime ? @default(now())
  updateAt DateTime @updatedAt
  records Record[]
}
model Record {
  id String @id @default(dbgenerated()) @map("_id") @db.ObjectId
  patientID String @db.ObjectId
  patient Patient @relation(fields: [patientID], references: [id])
  recordedAt DateTime @default(now())
  anglesOfCamera Angle[] 
  note String ?
  videos Video[]
  thumpImage String ?
  doctorName String ? //doctors Model
  createdAt DateTime @default(now())
  updateAt DateTime @updatedAt
}
model Video {
  id String @id @default(dbgenerated()) @map("_id") @db.ObjectId
	Path String
  Host String? //Host Seperate Model
	Views Int?
  duration Int?
  size Int?
  angleOfCamera Angle
  recordId String @db.ObjectId
  record Record @relation(fields: [recordId], references: [id])
}

Package.json

{
  "name": "xxxx",
  "version": "1.0.0",
  "description": "",
  "author": "xxx",
  "scripts": {
    "build": "tsc",
    "build:swc": "swc src --out-dir build  & tsc --skipLibCheck --noEmit",
    "start": "ts-node --transpile-only ./src/index.ts",
    "generate": "prisma generate",
    "pm2:start": "pm2 start build  -i max --name aflexgait-api",
    "pm2:start-single": "pm2 start build --name aflexgait-api",
    "prod": "npm i && npm run generate && npm run build && npm run pm2:start",
    "dev": "pnpm i && pnpm generate && pnpm build && pnpm pm2:start-single"
  },
  "prisma": {
    "schema": "prisma/schema.prisma"
  },
  "devDependencies": {
    "@types/node": "^16.9.1",
    "class-validator": "^0.13.1",
    "pm2": "^5.1.1",
    "prisma": "^3.0.2",
    "prisma-dbml-generator": "^0.7.0",
    "ts-node": "^10.2.1",
    "typegraphql-prisma": "^0.16.0",
    "typescript": "^4.4.3"
  },
  "dependencies": {
    "@prisma/client": "3.0.2",
    "@types/graphql-fields": "^1.3.4",
    "apollo-server": "^3.3.0",
    "graphql": "^15.5.3",
    "graphql-fields": "^2.0.3",
    "graphql-scalars": "^1.10.1",
    "reflect-metadata": "^0.1.13",
    "type-graphql": "^1.1.1"
  }
}

GraphQL Client Query

query Query {
  patients {
    id
    clinicID
    _count {
      records
    }
  }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Weakkycommented, Oct 6, 2021

Hey @muhad-bk, could you try on 3.2? I believe you were facing this issue since selectRelationCount wasn’t implemented on MongoDB.

This must’ve been fixed by https://github.com/prisma/prisma-engines/pull/2237 and should be available on the lastest on prisma@3.2

I’ll close this right now since I couldn’t reproduce, but I’ll re-open it if you confirm this is still an issue.

Thank you 🙏

0reactions
muhad-bkcommented, Oct 4, 2021

We tried with 3.1.1 and the same

Read more comments on GitHub >

github_iconTop Results From Across the Web

PANIC: called Option::unwrap() on a None value in query- ...
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 >
Code within try block still panics when calling unwrap on a ...
My understanding is that if the .unwrap is called on a None value, the try block will return a Result::Err.
Read more >
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 >
Null in Python: Understanding Python's NoneType Object
None by itself has no output, but printing it displays None to the console. Interestingly, print() itself has no return value. If you...
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