Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PANIC in query-engine\core\src\response_ir\internal.rs:334:86called Option::unwrap() on a None value #8861

Closed
dariusj18 opened this issue Aug 22, 2021 · 4 comments · Fixed by prisma/prisma-engines#2214
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: basic error report topic: client api topic: _count https://www.prisma.io/docs/concepts/components/prisma-client/aggregation-grouping-summarizing#count-
Milestone

Comments

@dariusj18
Copy link

dariusj18 commented Aug 22, 2021

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

Versions

Name Version
Node v14.16.0
OS windows
Prisma Client 2.29.1
Query Engine query-engine 1be4cd60b89afa04b192acb1ef47758a39810f3a
Database Postgres (see schema below)

Query

query {
  findManyPosts(
    skip: 5
    take: 5
    orderBy: [
      {
        id: asc
      }
    ]
  ) {
    id
    createdAt
    updatedAt
    is_deleted
    title
    user {
      id
      createdAt
      updatedAt
      is_deleted
      username
      _count {
        posts
      }
    }
  }
}

Logs

  prisma:client clientVersion: 2.29.1  
  prisma:engine Search for Query Engine in C:\PROJECT_FOLDER\node_modules\.prisma\client  
  prisma:engine {
  prisma:engine   cwd: 'C:\\PROJECT_FOLDER\\prisma'
  prisma:engine }  
  prisma:engine Search for Query Engine in C:\PROJECT_FOLDER\node_modules\.prisma\client  
  prisma:engine { flags: [ '--enable-raw-queries', '--port', '65337' ] }  
  prisma:engine stdout  Starting a postgresql pool with 9 connections.  
  prisma:engine stdout  Started http server on http://127.0.0.1:65337  
  prisma:engine Search for Query Engine in C:\PROJECT_FOLDER\node_modules\.prisma\client  
  prisma:engine Client Version: 2.29.1  
  prisma:engine Engine Version: query-engine 1be4cd60b89afa04b192acb1ef47758a39810f3a  
  prisma:engine Active provider: postgresql  
  prisma:engine stdout  PANIC in query-engine\core\src\response_ir\internal.rs:334:86
called `Option::unwrap()` on a `None` value  +2s
  prisma:engine {
  prisma:engine   error: Error: read ECONNRESET
  prisma:engine       at TCP.onStreamRead (internal/stream_base_commons.js:209:20) {
  prisma:engine     errno: -4077,
  prisma:engine     code: 'ECONNRESET',
  prisma:engine     syscall: 'read'
  prisma:engine   }
  prisma:engine }  
  prisma:engine {
  prisma:engine   error: Error: connect ECONNREFUSED 127.0.0.1:65337
  prisma:engine       at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
  prisma:engine     errno: -4078,
  prisma:engine     code: 'ECONNREFUSED',
  prisma:engine     syscall: 'connect',
  prisma:engine     address: '127.0.0.1',
  prisma:engine     port: 65337
  prisma:engine   }
  prisma:engine }  
  prisma:engine There is a child that still runs and we want to start again  
  prisma:engine {
  prisma:engine   cwd: 'C:\\PROJECT_FOLDER\\prisma'
  prisma:engine }  
  prisma:engine Search for Query Engine in C:\PROJECT_FOLDER\node_modules\.prisma\client  
  prisma:engine { flags: [ '--enable-raw-queries', '--port', '58392' ] }  
  prisma:engine stdout  Starting a postgresql pool with 9 connections.  
  prisma:engine stdout  Started http server on http://127.0.0.1:58392  
  prisma:engine Search for Query Engine in C:\PROJECT_FOLDER\node_modules\.prisma\client  
  prisma:engine stdout  PANIC in query-engine\core\src\response_ir\internal.rs:334:86
called `Option::unwrap()` on a `None` value  
  prisma:engine {
  prisma:engine   error: Error: read ECONNRESET
  prisma:engine       at TCP.onStreamRead (internal/stream_base_commons.js:209:20) {
  prisma:engine     errno: -4077,
  prisma:engine     code: 'ECONNRESET',
  prisma:engine     syscall: 'read'
  prisma:engine   }
  prisma:engine }  

Client Snippet

this.prisma.post.findMany({
  skip: offset,
  take: limit,
  orderBy,
  include: {
    user: {
      include: {
        _count: {
          select: {
            posts: true,
          }
        }
      }
    }
  }
});

Schema

datasource db {
  url      = env("POSTGRES_URL")
  provider = "postgres"
}

generator client {
  provider = "prisma-client-js"
  previewFeatures = ["interactiveTransactions", "selectRelationCount"]
}

model User {
  id         String   @id @default(uuid()) @db.Uuid
  createdAt  DateTime @default(now())
  updatedAt  DateTime @updatedAt
  is_deleted Boolean  @default(false)
  username   String

  posts Post[]
}

model Post {
  id         String   @id @default(uuid()) @db.Uuid
  createdAt  DateTime @default(now())
  updatedAt  DateTime @updatedAt
  is_deleted Boolean  @default(false)
  title      String

  user   User @relation(fields: [userId], references: [id])
  userId String   @db.Uuid
}
@dariusj18
Copy link
Author

Just tested and it still occurs with Prisma 2.30.0

@dariusj18
Copy link
Author

dariusj18 commented Aug 24, 2021

Here's a demo with the error

https://github.com/dariusj18/prisma_playground/tree/8861

@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. topic: _count https://www.prisma.io/docs/concepts/components/prisma-client/aggregation-grouping-summarizing#count- topic: client api team/client Issue for team Client. labels Aug 24, 2021
@hayes
Copy link
Contributor

hayes commented Aug 24, 2021

I just ran into the same issue using sqlite, so doesn't seem db specific.

@janpio janpio added topic: basic error report bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Sep 2, 2021
@janpio
Copy link
Member

janpio commented Sep 2, 2021

I can confirm this with your reproduction, when I create some simple data first, for example with this script:

import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient({
  log: [
    { emit: 'stdout', level: 'query' },
    { emit: 'stdout', level: 'info' },
    { emit: 'stdout', level: 'warn' },
    { emit: 'stdout', level: 'error' },
  ],
})

async function main() {
  const user = await prisma.user.create({ data: {
     username: "foo",
     posts: {
        create: [
          { title: 'How to make an omelette' },
          { title: 'How to eat an omelette' },
        ],
      }, 
  }})

  console.log(user);
  
}

main()
  .catch((e) => {
    throw e
  })
  .finally(async () => {
    await prisma.$disconnect()
  })

I can also confirm this happen with both PostgreSQL and SQLite.

Reproduction with create script and changed to SQLite is at https://github.com/janpio/prisma_playground/tree/8861

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: basic error report topic: client api topic: _count https://www.prisma.io/docs/concepts/components/prisma-client/aggregation-grouping-summarizing#count-
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants