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

Prisma Client regression bug after upgrading to 4.6.0: findMany errors with PANIC: index out of bounds: the len is 0 but the index is 0 #16195

Closed
DarioSiroki opened this issue Nov 9, 2022 · 5 comments · Fixed by prisma/prisma-engines#3375
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: findMany() topic: rust panic topic: $transaction Related to .$transaction(...) Client API
Milestone

Comments

@DarioSiroki
Copy link

Bug description

Panic when executing code provided below

thread 'tokio-runtime-worker' panicked at 'index out of bounds: the len is 0 but the index is 0', query-engine/core/src/query_document/mod.rs:74:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
/Users/dar0/projects/prisma-demo/node_modules/@prisma/client/runtime/index.js:34310
      throw new PrismaClientKnownRequestError(message, error2.code, this.client._clientVersion, error2.meta);
            ^
PrismaClientKnownRequestError: 
Invalid `prisma.balance.findMany()` invocation in
/Users/dar0/projects/prisma-demo/index.ts:12:20

   9     id: 1,
  10   },
  11 }),
→ 12 prisma.balance.findMany(
PANIC: index out of bounds: the len is 0 but the index is 0
    at RequestHandler.handleRequestError (/Users/dar0/projects/prisma-demo/node_modules/@prisma/client/runtime/index.js:34310:13)
    at RequestHandler.request (/Users/dar0/projects/prisma-demo/node_modules/@prisma/client/runtime/index.js:34293:12)
    at async PrismaClient._request (/Users/dar0/projects/prisma-demo/node_modules/@prisma/client/runtime/index.js:35273:16)
    at async Promise.all (index 1)
    at async main (/Users/dar0/projects/prisma-demo/index.ts:6:30) {
  code: 'GenericFailure',
  clientVersion: '4.6.0',
  meta: undefined
}

How to reproduce

Run the code below

Expected behavior

No response

Prisma information

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

datasource db {
    provider = "postgresql"
    url      = "postgres://postgres:root@localhost:5432/bug-demo"
}

model client {
    id       Int       @id @default(autoincrement())
    username String    @db.VarChar(100)
    balance  balance[]
}

model balance {
    id       Int    @id @default(autoincrement())
    amount   Int
    clientId Int
    client   client @relation(fields: [clientId], references: [id])
}
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

async function main() {
  const [client, balances] = await prisma.$transaction([
    prisma.client.findUniqueOrThrow({
      where: {
        id: 1,
      },
    }),
    prisma.balance.findMany(),
  ]);
}

main();

Environment & setup

  • OS: macOS, EC2 linux AMI
  • Database: Postgres
  • Node.js version: 16.15

Prisma Version

prisma                  : 4.6.0
@prisma/client          : 4.6.0
Current platform        : darwin-arm64
Query Engine (Node-API) : libquery-engine 2e719efb80b56a3f32d18a62489de95bb9c130e3 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine        : migration-engine-cli 2e719efb80b56a3f32d18a62489de95bb9c130e3 (at node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine    : introspection-core 2e719efb80b56a3f32d18a62489de95bb9c130e3 (at node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary           : prisma-fmt 2e719efb80b56a3f32d18a62489de95bb9c130e3 (at node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Format Wasm             : @prisma/prisma-fmt-wasm 4.6.0-53.2e719efb80b56a3f32d18a62489de95bb9c130e3
Default Engines Hash    : 2e719efb80b56a3f32d18a62489de95bb9c130e3
Studio                  : 0.476.0
Preview Features        : interactiveTransactions
@DarioSiroki DarioSiroki added the kind/bug A reported bug. label Nov 9, 2022
@tomhoule tomhoule added the team/client Issue for team Client. label Nov 9, 2022
@janpio janpio added topic: $transaction Related to .$transaction(...) Client API bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Nov 9, 2022
@Weakky
Copy link
Member

Weakky commented Nov 9, 2022

Hey @DarioSiroki,

We can reproduce this bug. Thanks for reporting 🙏

@Weakky Weakky added 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 Nov 9, 2022
@Jolg42 Jolg42 changed the title Regression bug after upgrading to 4.6.0 Prisma Client regression bug after upgrading to 4.6.0: findMany errors with PANIC: index out of bounds: the len is 0 but the index is 0 Nov 9, 2022
@Jolg42 Jolg42 added this to the 4.7.0 milestone Nov 9, 2022
Weakky added a commit to prisma/prisma-engines that referenced this issue Nov 9, 2022
@Jolg42
Copy link
Member

Jolg42 commented Nov 9, 2022

Hi @DarioSiroki !

We will prepare a patch release tomorrow.
We'll keep you updated as soon as it's available.

tomhoule pushed a commit to prisma/prisma-engines that referenced this issue Nov 9, 2022
@Jolg42
Copy link
Member

Jolg42 commented Nov 9, 2022

@DarioSiroki @SnowMarble
Could you try to update prisma and @prisma/client to the 4.6.1-dev.1 internal patch version that includes the fix and let us know if that solves this issue?

millsp added a commit that referenced this issue Nov 9, 2022
millsp added a commit that referenced this issue Nov 9, 2022
@DarioSiroki
Copy link
Author

Tried it, works, thanks for the quick fix!

@Jolg42
Copy link
Member

Jolg42 commented Nov 10, 2022

The official patch is out in 4.6.1

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: findMany() topic: rust panic topic: $transaction Related to .$transaction(...) Client API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants