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.

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`

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
DarioSirokicommented, Nov 10, 2022

Tried it, works, thanks for the quick fix!

2reactions
Jolg42commented, 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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prisma 4.6.1 Release - GitClear
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...
Read more >
Tweets with replies by Alex Ruheni (@ruheni_alex) / Twitter
Fixes in Prisma Client Prisma Client regression bug after upgrading to 4.6.0: findMany errors with PANIC: index out of bounds: the len is...
Read more >
Creating bug reports for Prisma
When creating a bug report, it's important that you include as much information as possible about your issue. That way, it's easier to...
Read more >
@prisma/engines: Versions | Openbase
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...
Read more >
Highlights - FeedsAnywhere
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...
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