Skip to content

Got error 'internal error: entered unreachable code' when trying to perform an upsert. #22947

@asynched

Description

@asynched

Bug description

Got error: PrismaClientRustPanicError: Invalid 'client.tag.upsert()' when trying to perform a seed using Prisma + SQLite.

How to reproduce

  1. Clone this repository: https://github.com/asynched/prisma-upsert-bug-repro
  2. Install the dependencies with bun i
  3. Run bun prisma migrate dev
  4. Run bun run seed
  5. See error

Expected behavior

Expected tags to be created or updated when running client.tag.upsert

Prisma information

Schema

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

generator client {
  provider = "prisma-client-js"
}

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

model User {
  id       String  @id() @default(cuid())
  name     String
  username String  @unique()
  email    String  @unique()
  avatar   String
  password String
  bio      String  @default("")
  banned   Boolean @default(false)
  verified Boolean @default(false)

  videos   Video[]
  sessions Session[]

  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @default(now()) @updatedAt() @map("updated_at")

  @@map("users")
}

model Session {
  id        String @id() @default(cuid())
  token     String @unique()
  ip        String
  userAgent String @map("user_agent")
  device    String

  userId String @map("user_id")
  user   User   @relation(fields: [userId], references: [id])

  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @default(now()) @updatedAt() @map("updated_at")

  @@map("sessions")
}

model Video {
  id          String @id() @default(cuid())
  title       String
  description String
  url         String @unique()

  userId String     @map("user_id")
  user   User       @relation(fields: [userId], references: [id])
  tags   VideoTag[]

  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @default(now()) @updatedAt() @map("updated_at")

  @@map("videos")
}

model Tag {
  id   String @id() @default(cuid())
  name String @unique()

  videos VideoTag[]

  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @default(now()) @updatedAt() @map("updated_at")

  @@map("tags")
}

model VideoTag {
  videoId String @map("video_id")
  tagId   String @map("tag_id")

  video Video @relation(fields: [videoId], references: [id])
  tag   Tag   @relation(fields: [tagId], references: [id])

  @@id([videoId, tagId])
  @@map("video_tags")
}

Query

import { PrismaClient } from '@prisma/client'

async function seed() {
  const client = new PrismaClient()

  console.log('Creating user')
  const user = await client.user.create({
    data: {
      name: 'Jeffrey Danley',
      email: 'jeff@mail.com',
      username: 'Fireship',
      avatar:
        'https://yt3.googleusercontent.com/ytc/AIf8zZTUVa5AeFd3m5-4fdY2hEaKof3Byp8VruZ0f0FNEA=s100-c-k-c0x00ffffff-no-rj',
      password: 'password123',
      bio: 'High-intensity ⚡ code tutorials and tech news to help you ship your app faster. New videos every week covering the topics every programmer should know.',
    },
  })

  const videos = [
    {
      name: 'My browser, my paste.',
      url: '/static/videos/browser-paste.mp4',
      tags: ['Programming', 'Web Development', 'JavaScript'],
    },
    {
      name: 'Yo mama so FAT32',
      url: '/static/videos/file-types.mp4',
      tags: ['Programming', 'Operating Systems'],
    },
    {
      name: 'CSS in 3D',
      url: '/static/videos/pages-in-3d.mp4',
      tags: ['Programming', 'Web Development', 'CSS'],
    },
    {
      name: 'Web development in a nutshell',
      url: '/static/videos/story-of-web.mp4',
      tags: ['Programming', 'Web Development'],
    },
  ]

  for (const video of videos) {
    console.log('Creating video')
    const tags = await Promise.all(
      video.tags.map((name) =>
        client.tag.upsert({
          where: { name },
          update: {},
          create: { name },
        })
      )
    )

    const created = await client.video.create({
      data: {
        title: video.name,
        description: video.name,
        url: video.url,
        userId: user.id,
      },
    })

    console.log('Adding tags')
    await Promise.all(
      tags.map((tag) =>
        client.videoTag.create({ data: { videoId: created.id, tagId: tag.id } })
      )
    )
  }
}

seed()

Logs

  prisma:tryLoadEnv  Environment variables not found at null +0ms
  prisma:tryLoadEnv  Environment variables loaded from /home/ederlima/www/education-shorts/.env +0ms
  prisma:client  checkPlatformCaching:postinstall undefined +0ms
  prisma:client  checkPlatformCaching:ciName undefined +0ms
  prisma:tryLoadEnv  Environment variables not found at null +2ms
  prisma:tryLoadEnv  Environment variables loaded from /home/ederlima/www/education-shorts/.env +0ms
  prisma:client  dirname /home/ederlima/www/education-shorts/node_modules/.prisma/client +0ms
  prisma:client  relativePath ../../../prisma +0ms
  prisma:client  cwd /home/ederlima/www/education-shorts/prisma +0ms
  prisma:client  clientVersion 5.9.1 +0ms
  prisma:client:libraryEngine  internalSetup +0ms
Creating user
  prisma:client  Prisma Client call: +4ms
  prisma:client  prisma.user.create({
  data: {
    name: "Jeffrey Danley",
    email: "jeff@mail.com",
    username: "Fireship",
    avatar: "https://yt3.googleusercontent.com/ytc/AIf8zZTUVa5AeFd3m5-4fdY2hEaKof3Byp8VruZ0f0FNEA=s100-c-k-c0x00ffffff-no-rj",
    password: "password123",
    bio: "High-intensity ⚡ code tutorials and tech news to help you ship your app faster. New videos every week covering the topics every programmer should know."
  }
}) +1ms
  prisma:client  Generated request: +0ms
  prisma:client  {
  "modelName": "User",
  "action": "createOne",
  "query": {
    "arguments": {
      "data": {
        "name": "Jeffrey Danley",
        "email": "jeff@mail.com",
        "username": "Fireship",
        "avatar": "https://yt3.googleusercontent.com/ytc/AIf8zZTUVa5AeFd3m5-4fdY2hEaKof3Byp8VruZ0f0FNEA=s100-c-k-c0x00ffffff-no-rj",
        "password": "password123",
        "bio": "High-intensity ⚡ code tutorials and tech news to help you ship your app faster. New videos every week covering the topics every programmer should know."
      }
    },
    "selection": {
      "$composites": true,
      "$scalars": true
    }
  }
}
 +0ms
  prisma:client:libraryEngine  sending request, this.libraryStarted: false +4ms
  prisma:get-platform  Found distro info:
{
  "targetDistro": "debian",
  "familyDistro": "debian",
  "originalDistro": "ubuntu"
} +0ms
  prisma:get-platform  Trying platform-specific paths for "debian" (and "ubuntu") +0ms
  prisma:get-platform  Found libssl.so file using platform-specific paths: libssl.so.3 +2ms
  prisma:get-platform  The parsed libssl version is: 3.0.x +0ms
  prisma:client:engines:resolveEnginePath  enginePath /home/ederlima/www/education-shorts/node_modules/.prisma/client/libquery_engine-debian-openssl-3.0.x.so.node +0ms
  prisma:client:libraryEngine  library starting +8ms
  prisma:client:libraryEngine  library started +1ms
Creating video
  prisma:client  Prisma Client call: +17ms
  prisma:client  prisma.tag.upsert({
  where: {
    name: "Programming"
  },
  update: {},
  create: {
    name: "Programming"
  }
}) +1ms
  prisma:client  Generated request: +0ms
  prisma:client  {
  "modelName": "Tag",
  "action": "upsertOne",
  "query": {
    "arguments": {
      "where": {
        "name": "Programming"
      },
      "update": {},
      "create": {
        "name": "Programming"
      }
    },
    "selection": {
      "$composites": true,
      "$scalars": true
    }
  }
}
 +0ms
  prisma:client:libraryEngine  sending request, this.libraryStarted: true +9ms
  prisma:client  Prisma Client call: +0ms
  prisma:client  prisma.tag.upsert({
  where: {
    name: "Web Development"
  },
  update: {},
  create: {
    name: "Web Development"
  }
}) +0ms
  prisma:client  Generated request: +0ms
  prisma:client  {
  "modelName": "Tag",
  "action": "upsertOne",
  "query": {
    "arguments": {
      "where": {
        "name": "Web Development"
      },
      "update": {},
      "create": {
        "name": "Web Development"
      }
    },
    "selection": {
      "$composites": true,
      "$scalars": true
    }
  }
}
 +0ms
  prisma:client:libraryEngine  sending request, this.libraryStarted: true +0ms
  prisma:client  Prisma Client call: +0ms
  prisma:client  prisma.tag.upsert({
  where: {
    name: "JavaScript"
  },
  update: {},
  create: {
    name: "JavaScript"
  }
}) +0ms
  prisma:client  Generated request: +0ms
  prisma:client  {
  "modelName": "Tag",
  "action": "upsertOne",
  "query": {
    "arguments": {
      "where": {
        "name": "JavaScript"
      },
      "update": {},
      "create": {
        "name": "JavaScript"
      }
    },
    "selection": {
      "$composites": true,
      "$scalars": true
    }
  }
}
 +0ms
  prisma:client:libraryEngine  sending request, this.libraryStarted: true +1ms
thread 'tokio-runtime-worker' panicked at libs/user-facing-errors/src/quaint.rs:167:18:
internal error: entered unreachable code
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'tokio-runtime-worker' panicked at libs/user-facing-errors/src/quaint.rs:167:18:
internal error: entered unreachable code
  prisma:client:request_handler  PrismaClientRustPanicError: internal error: entered unreachable code

This is a non-recoverable error which probably happens when the Prisma Query Engine has a panic.

https://github.com/prisma/prisma/issues/new?body=Hi+Prisma+Team%21+My+Prisma+Client+just+crashed.+This+is+the+report%3A%0A%23%23+Versions%0A%0A%7C+Name++++++++++++%7C+Version++++++++++++%7C%0A%7C-----------------%7C--------------------%7C%0A%7C+Node++++++++++++%7C+v20.6.1++++++++++++%7C+%0A%7C+OS++++++++++++++%7C+debian-openssl-3.0.x%7C%0A%7C+Prisma+Client+++%7C+5.9.1++++++++++++++%7C%0A%7C+Query+Engine++++%7C+23fdc5965b1e05fc54e5f26ed3de66776b93de64%7C%0A%7C+Database++++++++%7C+sqlite+++++++++++++%7C%0A%0A%0A%0A%23%23+Logs%0A%60%60%60%0Aprisma%3AtryLoadEnv+Environment+variables+not+found+at+null%0Aprisma%3AtryLoadEnv+Environment+variables+loaded+from+%2Fhome%2Federlima%2Fwww%2Feducation-shorts%2F.env%0Aprisma%3Aclient+checkPlatformCaching%3Apostinstall+%0Aprisma%3Aclient+checkPlatformCaching%3AciName+%0Aprisma%3AtryLoadEnv+Environment+variables+not+found+at+null%0Aprisma%3AtryLoadEnv+Environment+variables+loaded+from+%2Fhome%2Federlima%2Fwww%2Feducation-shorts%2F.env%0Aprisma%3Aclient+dirname+%2Fhome%2Federlima%2Fwww%2Feducation-shorts%2Fnode_modules%2F.prisma%2Fclient%0Aprisma%3Aclient+relativePath+..%2F..%2F..%2Fprisma%0Aprisma%3Aclient+cwd+%2Fhome%2Federlima%2Fwww%2Feducation-shorts%2Fprisma%0Aprisma%3Aclient+clientVersion+5.9.1%0Aprisma%3Aclient%3AlibraryEngine+internalSetup%0Aprisma%3Aclient+Prisma+Client+call%3A%0Aprisma%3Aclient+prisma.user.create%28%7B%0A++data%3A+%7B%0A++++name%3A+%22Jeffrey+Danley%22%2C%0A++++email%3A+%22jeff%40mail.com%22%2C%0A++++username%3A+%22Fireship%22%2C%0A++++avatar%3A+%22https%3A%2F%2Fyt3.googleusercontent.com%2Fytc%2FAIf8zZTUVa5AeFd3m5-4fdY2hEaKof3Byp8VruZ0f0FNEA%3Ds100-c-k-c0x00ffffff-no-rj%22%2C%0A++++password%3A+%22password123%22%2C%0A++++bio%3A+%22High-intensity+%E2%9A%A1+code+tutorials+and+tech+news+to+help+you+ship+your+app+faster.+New+videos+every+week+covering+the+topics+every+programmer+should+know.%22%0A++%7D%0A%7D%29%0Aprisma%3Aclient+Generated+request%3A%0Aprisma%3Aclient+%7B%0A++%22modelName%22%3A+%22User%22%2C%0A++%22action%22%3A+%22createOne%22%2C%0A++%22query%22%3A+%7B%0A++++%22arguments%22%3A+%7B%0A++++++%22data%22%3A+%7B%0A++++++++%22name%22%3A+%22Jeffrey+Danley%22%2C%0A++++++++%22email%22%3A+%22jeff%40mail.com%22%2C%0A++++++++%22username%22%3A+%22Fireship%22%2C%0A++++++++%22avatar%22%3A+%22https%3A%2F%2Fyt3.googleusercontent.com%2Fytc%2FAIf8zZTUVa5AeFd3m5-4fdY2hEaKof3Byp8VruZ0f0FNEA%3Ds100-c-k-c0x00ffffff-no-rj%22%2C%0A++++++++%22password%22%3A+%22password123%22%2C%0A++++++++%22bio%22%3A+%22High-intensity+%E2%9A%A1+code+tutorials+and+tech+news+to+help+you+ship+your+app+faster.+New+videos+every+week+covering+the+topics+every+programmer+should+know.%22%0A++++++%7D%0A++++%7D%2C%0A++++%22selection%22%3A+%7B%0A++++++%22%24composites%22%3A+true%2C%0A++++++%22%24scalars%22%3A+true%0A++++%7D%0A++%7D%0A%7D%0A%0Aprisma%3Aclient%3AlibraryEngine+sending+request%2C+this.libraryStarted%3A+false%0Aprisma%3Aget-platform+Found+distro+info%3A%0A%7B%0A++%22targetDistro%22%3A+%22debian%22%2C%0A++%22familyDistro%22%3A+%22debian%22%2C%0A++%22originalDistro%22%3A+%22ubuntu%22%0A%7D%0Aprisma%3Aget-platform+Trying+platform-specific+paths+for+%22debian%22+%28and+%22ubuntu%22%29%0Aprisma%3Aget-platform+Found+libssl.so+file+using+platform-specific+paths%3A+libssl.so.3%0Aprisma%3Aget-platform+The+parsed+libssl+version+is%3A+3.0.x%0Aprisma%3Aclient%3Aengines%3AresolveEnginePath+enginePath+%2Fhome%2Federlima%2Fwww%2Feducation-shorts%2Fnode_modules%2F.prisma%2Fclient%2Flibquery_engine-debian-openssl-3.0.x.so.node%0Aprisma%3Aclient%3AlibraryEngine+library+starting%0Aprisma%3Aclient%3AlibraryEngine+library+started%0Aprisma%3Aclient+Prisma+Client+call%3A%0Aprisma%3Aclient+prisma.tag.upsert%28%7B%0A++where%3A+%7B%0A++++name%3A+%22Programming%22%0A++%7D%2C%0A++update%3A+%7B%7D%2C%0A++create%3A+%7B%0A++++name%3A+%22Programming%22%0A++%7D%0A%7D%29%0Aprisma%3Aclient+Generated+request%3A%0Aprisma%3Aclient+%7B%0A++%22modelName%22%3A+%22Tag%22%2C%0A++%22action%22%3A+%22upsertOne%22%2C%0A++%22query%22%3A+%7B%0A++++%22arguments%22%3A+%7B%0A++++++%22where%22%3A+%7B%0A++++++++%22name%22%3A+%22Programming%22%0A++++++%7D%2C%0A++++++%22update%22%3A+%7B%7D%2C%0A++++++%22create%22%3A+%7B%0A++++++++%22name%22%3A+%22Programming%22%0A++++++%7D%0A++++%7D%2C%0A++++%22selection%22%3A+%7B%0A++++++%22%24composites%22%3A+true%2C%0A++++++%22%24scalars%22%3A+true%0A++++%7D%0A++%7D%0A%7D%0A%0Aprisma%3Aclient%3AlibraryEngine+sending+request%2C+this.libraryStarted%3A+true%0Aprisma%3Aclient+Prisma+Client+call%3A%0Aprisma%3Aclient+prisma.tag.upsert%28%7B%0A++where%3A+%7B%0A++++name%3A+%22Web+Development%22%0A++%7D%2C%0A++update%3A+%7B%7D%2C%0A++create%3A+%7B%0A++++name%3A+%22Web+Development%22%0A++%7D%0A%7D%29%0Aprisma%3Aclient+Generated+request%3A%0Aprisma%3Aclient+%7B%0A++%22modelName%22%3A+%22Tag%22%2C%0A++%22action%22%3A+%22upsertOne%22%2C%0A++%22query%22%3A+%7B%0A++++%22arguments%22%3A+%7B%0A++++++%22where%22%3A+%7B%0A++++++++%22name%22%3A+%22Web+Development%22%0A++++++%7D%2C%0A++++++%22update%22%3A+%7B%7D%2C%0A++++++%22create%22%3A+%7B%0A++++++++%22name%22%3A+%22Web+Development%22%0A++++++%7D%0A++++%7D%2C%0A++++%22selection%22%3A+%7B%0A++++++%22%24composites%22%3A+true%2C%0A++++++%22%24scalars%22%3A+true%0A++++%7D%0A++%7D%0A%7D%0A%0Aprisma%3Aclient%3AlibraryEngine+sending+request%2C+this.libraryStarted%3A+true%0Aprisma%3Aclient+Prisma+Client+call%3A%0Aprisma%3Aclient+prisma.tag.upsert%28%7B%0A++where%3A+%7B%0A++++name%3A+%22JavaScript%22%0A++%7D%2C%0A++update%3A+%7B%7D%2C%0A++create%3A+%7B%0A++++name%3A+%22JavaScript%22%0A++%7D%0A%7D%29%0Aprisma%3Aclient+Generated+request%3A%0Aprisma%3Aclient+%7B%0A++%22modelName%22%3A+%22Tag%22%2C%0A++%22action%22%3A+%22upsertOne%22%2C%0A++%22query%22%3A+%7B%0A++++%22arguments%22%3A+%7B%0A++++++%22where%22%3A+%7B%0A++++++++%22name%22%3A+%22JavaScript%22%0A++++++%7D%2C%0A++++++%22update%22%3A+%7B%7D%2C%0A++++++%22create%22%3A+%7B%0A++++++++%22name%22%3A+%22JavaScript%22%0A++++++%7D%0A++++%7D%2C%0A++++%22selection%22%3A+%7B%0A++++++%22%24composites%22%3A+true%2C%0A++++++%22%24scalars%22%3A+true%0A++++%7D%0A++%7D%0A%7D%0A%0Aprisma%3Aclient%3AlibraryEngine+sending+request%2C+this.libraryStarted%3A+true%0A%60%60%60%0A%0A%23%23+Client+Snippet%0A%60%60%60ts%0A%2F%2F+PLEASE+FILL+YOUR+CODE+SNIPPET+HERE%0A%60%60%60%0A%0A%23%23+Schema%0A%60%60%60prisma%0A%2F%2F+PLEASE+ADD+YOUR+SCHEMA+HERE+IF+POSSIBLE%0A%60%60%60%0A%0A%23%23+Prisma+Engine+Query%0A%60%60%60%0A%7B%22X%22%3Atrue%7D%7D%7D%0A%60%60%60%0A&title=internal+error%3A+entered+unreachable+code&template=bug_report.yml

If you want the Prisma team to look into it, please open the link above 🙏
To increase the chance of success, please post your schema and a snippet of
how you used Prisma Client in the issue. 

    at qr.buildQueryError (/home/ederlima/www/education-shorts/node_modules/@prisma/client/runtime/library.js:117:813)
    at qr.request (/home/ederlima/www/education-shorts/node_modules/@prisma/client/runtime/library.js:116:4074)
    at async Object.singleLoader (/home/ederlima/www/education-shorts/node_modules/@prisma/client/runtime/library.js:126:5212)
    at async ai.request (/home/ederlima/www/education-shorts/node_modules/@prisma/client/runtime/library.js:126:5704)
    at async l (/home/ederlima/www/education-shorts/node_modules/@prisma/client/runtime/library.js:131:9709)
    at async Promise.all (index 1)
    at seed (/home/ederlima/www/education-shorts/scripts/seed.ts:44:18) {
  clientVersion: '5.9.1'
} +0ms
/home/ederlima/www/education-shorts/node_modules/@prisma/client/runtime/library.js:126
`)}var No=({clientMethod:e,activeProvider:t})=>r=>{let n="",i;if(Array.isArray(r)){let[o,...s]=r;n=o,i={values:Br(s||[]),__prismaRawParameters__:!0}}else switch(t){case"sqlite":case"mysql":{n=r.sql,i={values:Br(r.values),__prismaRawParameters__:!0};break}case"cockroachdb":case"postgresql":case"postgres":{n=r.text,i={values:Br(r.values),__prismaRawParameters__:!0};break}case"sqlserver":{n=Ql(r),i={values:Br(r.values),__prismaRawParameters__:!0};break}default:throw new Error(`The ${t} provider does not support ${e}`)}return i?.values?Wl(`prisma.${e}(${n}, ${i.values})`):Wl(`prisma.${e}(${n})`),{query:n,parameters:i}},zl={requestArgsToMiddlewareArgs(e){return[e.strings,...e.values]},middlewareArgsToRequestArgs(e){let[t,...r]=e;return new fe(t,r)}},Yl={requestArgsToMiddlewareArgs(e){return[e]},middlewareArgsToRequestArgs(e){return e[0]}};function Lo(e){return function(r){let n,i=(o=e)=>{try{return o===void 0||o?.kind==="itx"?n??(n=Zl(r(o))):Zl(r(o))}catch(s){return Promise.reject(s)}};return{then(o,s){return i().then(o,s)},catch(o){return i().catch(o)},finally(o){return i().finally(o)},requestTransaction(o){let s=i(o);return s.requestTransaction?s.requestTransaction(o):s},[Symbol.toStringTag]:"PrismaPromise"}}}function Zl(e){return typeof e.then=="function"?e:Promise.resolve(e)}var Xl={isEnabled(){return!1},getTraceParent(){return"00-10-10-00"},async createEngineSpan(){},getActiveContext(){},runInChildSpan(e,t){return t()}},$o=class{isEnabled(){return this.getGlobalTracingHelper().isEnabled()}getTraceParent(t){return this.getGlobalTracingHelper().getTraceParent(t)}createEngineSpan(t){return this.getGlobalTracingHelper().createEngineSpan(t)}getActiveContext(){return this.getGlobalTracingHelper().getActiveContext()}runInChildSpan(t,r){return this.getGlobalTracingHelper().runInChildSpan(t,r)}getGlobalTracingHelper(){return globalThis.PRISMA_INSTRUMENTATION?.helper??Xl}};function eu(e){return e.includes("tracing")?new $o:Xl}function tu(e,t=()=>{}){let r,n=new Promise(i=>r=i);return{then(i){return--e===0&&r(t()),i?.(n)}}}function ru(e){return typeof e=="string"?e:e.reduce((t,r)=>{let n=typeof r=="string"?r:r.level;return n==="query"?t:t&&(r==="info"||t==="info")?"info":n},void 0)}var ni=class{constructor(){this._middlewares=[]}use(t){this._middlewares.push(t)}get(t){return this._middlewares[t]}has(t){return!!this._middlewares[t]}length(){return this._middlewares.length}};var iu=D(Ui());function ii(e){return typeof e.batchRequestIdx=="number"}function oi(e){return e===null?e:Array.isArray(e)?e.map(oi):typeof e=="object"?Tg(e)?_g(e):kt(e,oi):e}function Tg(e){return e!==null&&typeof e=="object"&&typeof e.$type=="string"}function _g({$type:e,value:t}){switch(e){case"BigInt":return BigInt(t);case"Bytes":return Buffer.from(t,"base64");case"DateTime":return new Date(t);case"Decimal":return new Ne(t);case"Json":return JSON.parse(t);default:gt(t,"Unknown tagged value")}}function nu(e){if(e.action!=="findUnique"&&e.action!=="findUniqueOrThrow")return;let t=[];return e.modelName&&t.push(e.modelName),e.query.arguments&&t.push(qo(e.query.arguments)),t.push(qo(e.query.selection)),t.join("")}function qo(e){return`(${Object.keys(e).sort().map(r=>{let n=e[r];return typeof n=="object"&&n!==null?`(${r} ${qo(n)})`:r}).join(" ")})`}var Cg={aggregate:!1,aggregateRaw:!1,createMany:!0,createOne:!0,deleteMany:!0,deleteOne:!0,executeRaw:!0,findFirst:!1,findFirstOrThrow:!1,findMany:!1,findRaw:!1,findUnique:!1,findUniqueOrThrow:!1,groupBy:!1,queryRaw:!1,runCommandRaw:!0,updateMany:!0,updateOne:!0,upsertOne:!0};function jo(e){return Cg[e]}var si=class{constructor(t){this.options=t;this.tickActive=!1;this.batches={}}request(t){let r=this.options.batchBy(t);return r?(this.batches[r]||(this.batches[r]=[],this.tickActive||(this.tickActive=!0,process.nextTick(()=>{this.dispatchBatches(),this.tickActive=!1}))),new Promise((n,i)=>{this.batches[r].push({request:t,resolve:n,reject:i})})):this.options.singleLoader(t)}dispatchBatches(){for(let t in this.batches){let r=this.batches[t];delete this.batches[t],r.length===1?this.options.singleLoader(r[0].request).then(n=>{n instanceof Error?r[0].reject(n):r[0].resolve(n)}).catch(n=>{r[0].reject(n)}):(r.sort((n,i)=>this.options.batchOrder(n.request,i.request)),this.options.batchLoader(r.map(n=>n.request)).then(n=>{if(n instanceof Error)for(let i=0;i<r.length;i++)r[i].reject(n);else for(let i=0;i<r.length;i++){let o=n[i];o instanceof Error?r[i].reject(o):r[i].resolve(o)}}).catch(n=>{for(let i=0;i<r.length;i++)r[i].reject(n)}))}}get[Symbol.toStringTag](){return"DataLoader"}};var Ag=$("prisma:client:request_handler"),ai=class{constructor(t,r){this.logEmitter=r,this.client=t,this.dataloader=new si({batchLoader:Ha(async({requests:n,customDataProxyFetch:i})=>{let{transaction:o,otelParentCtx:s}=n[0],a=n.map(p=>p.protocolQuery),l=this.client._tracingHelper.getTraceParent(s),u=n.some(p=>jo(p.protocolQuery.action));return(await this.client._engine.requestBatch(a,{traceparent:l,transaction:Rg(o),containsWrite:u,customDataProxyFetch:i})).map((p,d)=>{if(p instanceof Error)return p;try{return this.mapQueryEngineResult(n[d],p)}catch(f){return f}})}),singleLoader:async n=>{let i=n.transaction?.kind==="itx"?ou(n.transaction):void 0,o=await this.client._engine.request(n.protocolQuery,{traceparent:this.client._tracingHelper.getTraceParent(),interactiveTransaction:i,isWrite:jo(n.protocolQuery.action),customDataProxyFetch:n.customDataProxyFetch});return this.mapQueryEngineResult(n,o)},batchBy:n=>n.transaction?.id?`transaction-${n.transaction.id}`:nu(n.protocolQuery),batchOrder(n,i){return n.transaction?.kind==="batch"&&i.transaction?.kind==="batch"?n.transaction.index-i.transaction.index:0}})}async request(t){try{return await this.dataloader.request(t)}catch(r){let{clientMethod:n,callsite:i,transaction:o,args:s,modelName:a}=t;this.handleAndLogRequestError({error:r,clientMethod:n,callsite:i,transaction:o,args:s,modelName:a})}}mapQueryEngineResult({dataPath:t,unpacker:r},n){let i=n?.data,o=n?.elapsed,s=this.unpack(i,t,r);return process.env.PRISMA_CLIENT_GET_TIME?{data:s,elapsed:o}:s}handleAndLogRequestError(t){try{this.handleRequestError(t)}catch(r){throw this.logEmitter&&this.logEmitter.emit("error",{message:r.message,target:t.clientMethod,timestamp:new Date}),r}}handleRequestError({error:t,clientMethod:r,callsite:n,transaction:i,args:o,modelName:s}){if(Ag(t),Mg(t,i)||t instanceof Ve)throw t;if(t instanceof H&&Sg(t)){let l=su(t.meta);ri({args:o,errors:[l],callsite:n,errorFormat:this.client._errorFormat,originalMethod:r,clientVersion:this.client._clientVersion})}let a=t.message;if(n&&(a=Kt({callsite:n,originalMethod:r,isPanic:t.isPanic,showColors:this.client._errorFormat==="pretty",message:a})),a=this.sanitizeMessage(a),t.code){let l=s?{modelName:s,...t.meta}:t.meta;throw new H(a,{code:t.code,clientVersion:this.client._clientVersion,meta:l,batchRequestIdx:t.batchRequestIdx})}else{if(t.isPanic)throw new be(a,this.client._clientVersion);if(t instanceof W)throw new W(a,{clientVersion:this.client._clientVersion,batchRequestIdx:t.batchRequestIdx});if(t instanceof O)throw new O(a,this.client._clientVersion);if(t instanceof be)throw new be(a,this.client._clientVersion)}throw t.clientVersion=this.client._clientVersion,t}sanitizeMessage(t){return this.client._errorFormat&&this.client._errorFormat!=="pretty"?(0,iu.default)(t):t}unpack(t,r,n){if(!t||(t.data&&(t=t.data),!t))return t;let i=Object.values(t)[0],o=r.filter(a=>a!=="select"&&a!=="include"),s=oi(co(i,o));return n?n(s):s}get[Symbol.toStringTag](){return"RequestHandler"}};function Rg(e){if(e){if(e.kind==="batch")return{kind:"batch",options:{isolationLevel:e.isolationLevel}};if(e.kind==="itx")return{kind:"itx",options:ou(e)};gt(e,"Unknown transaction kind")}}function ou(e){return{id:e.id,payload:e.payload}}function Mg(e,t){return ii(e)&&t?.kind==="batch"&&e.batchRequestIdx!==t.index}function Sg(e){return e.code==="P2009"||e.code==="P2012"}function su(e){if(e.kind==="Union")return{kind:"Union",errors:e.errors.map(su)};if(Array.isArray(e.selectionPath)){let[,...t]=e.selectionPath;return{...e,selectionPath:t}}return e}var au="5.9.1";var lu=au;function uu(e){return e.map(t=>{let r={};for(let n of Object.keys(t))r[n]=cu(t[n]);return r})}function cu({prisma__type:e,prisma__value:t}){switch(e){case"bigint":return BigInt(t);case"bytes":return Buffer.from(t,"base64");case"decimal":return new Ne(t);case"datetime":case"date":return new Date(t);case"time":return new Date(`1970-01-01T${t}Z`);case"array":return t.map(cu);default:return t}}var fu=D(Do());var U=class extends Error{constructor(t){super(t+`
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

PrismaClientRustPanicError: 
Invalid `client.tag.upsert()` invocation in
/home/ederlima/www/education-shorts/scripts/seed.ts:46:20

  43 console.log('Creating video')
  44 const tags = await Promise.all(
  45   video.tags.map((name) =>
→ 46     client.tag.upsert(
internal error: entered unreachable code

This is a non-recoverable error which probably happens when the Prisma Query Engine has a panic.

https://github.com/prisma/prisma/issues/new?body=Hi+Prisma+Team%21+My+Prisma+Client+just+crashed.+This+is+the+report%3A%0A%23%23+Versions%0A%0A%7C+Name++++++++++++%7C+Version++++++++++++%7C%0A%7C-----------------%7C--------------------%7C%0A%7C+Node++++++++++++%7C+v20.6.1++++++++++++%7C+%0A%7C+OS++++++++++++++%7C+debian-openssl-3.0.x%7C%0A%7C+Prisma+Client+++%7C+5.9.1++++++++++++++%7C%0A%7C+Query+Engine++++%7C+23fdc5965b1e05fc54e5f26ed3de66776b93de64%7C%0A%7C+Database++++++++%7C+sqlite+++++++++++++%7C%0A%0A%0A%0A%23%23+Logs%0A%60%60%60%0Aprisma%3AtryLoadEnv+Environment+variables+not+found+at+null%0Aprisma%3AtryLoadEnv+Environment+variables+loaded+from+%2Fhome%2Federlima%2Fwww%2Feducation-shorts%2F.env%0Aprisma%3Aclient+checkPlatformCaching%3Apostinstall+%0Aprisma%3Aclient+checkPlatformCaching%3AciName+%0Aprisma%3AtryLoadEnv+Environment+variables+not+found+at+null%0Aprisma%3AtryLoadEnv+Environment+variables+loaded+from+%2Fhome%2Federlima%2Fwww%2Feducation-shorts%2F.env%0Aprisma%3Aclient+dirname+%2Fhome%2Federlima%2Fwww%2Feducation-shorts%2Fnode_modules%2F.prisma%2Fclient%0Aprisma%3Aclient+relativePath+..%2F..%2F..%2Fprisma%0Aprisma%3Aclient+cwd+%2Fhome%2Federlima%2Fwww%2Feducation-shorts%2Fprisma%0Aprisma%3Aclient+clientVersion+5.9.1%0Aprisma%3Aclient%3AlibraryEngine+internalSetup%0Aprisma%3Aclient+Prisma+Client+call%3A%0Aprisma%3Aclient+prisma.user.create%28%7B%0A++data%3A+%7B%0A++++name%3A+%22Jeffrey+Danley%22%2C%0A++++email%3A+%22jeff%40mail.com%22%2C%0A++++username%3A+%22Fireship%22%2C%0A++++avatar%3A+%22https%3A%2F%2Fyt3.googleusercontent.com%2Fytc%2FAIf8zZTUVa5AeFd3m5-4fdY2hEaKof3Byp8VruZ0f0FNEA%3Ds100-c-k-c0x00ffffff-no-rj%22%2C%0A++++password%3A+%22password123%22%2C%0A++++bio%3A+%22High-intensity+%E2%9A%A1+code+tutorials+and+tech+news+to+help+you+ship+your+app+faster.+New+videos+every+week+covering+the+topics+every+programmer+should+know.%22%0A++%7D%0A%7D%29%0Aprisma%3Aclient+Generated+request%3A%0Aprisma%3Aclient+%7B%0A++%22modelName%22%3A+%22User%22%2C%0A++%22action%22%3A+%22createOne%22%2C%0A++%22query%22%3A+%7B%0A++++%22arguments%22%3A+%7B%0A++++++%22data%22%3A+%7B%0A++++++++%22name%22%3A+%22Jeffrey+Danley%22%2C%0A++++++++%22email%22%3A+%22jeff%40mail.com%22%2C%0A++++++++%22username%22%3A+%22Fireship%22%2C%0A++++++++%22avatar%22%3A+%22https%3A%2F%2Fyt3.googleusercontent.com%2Fytc%2FAIf8zZTUVa5AeFd3m5-4fdY2hEaKof3Byp8VruZ0f0FNEA%3Ds100-c-k-c0x00ffffff-no-rj%22%2C%0A++++++++%22password%22%3A+%22password123%22%2C%0A++++++++%22bio%22%3A+%22High-intensity+%E2%9A%A1+code+tutorials+and+tech+news+to+help+you+ship+your+app+faster.+New+videos+every+week+covering+the+topics+every+programmer+should+know.%22%0A++++++%7D%0A++++%7D%2C%0A++++%22selection%22%3A+%7B%0A++++++%22%24composites%22%3A+true%2C%0A++++++%22%24scalars%22%3A+true%0A++++%7D%0A++%7D%0A%7D%0A%0Aprisma%3Aclient%3AlibraryEngine+sending+request%2C+this.libraryStarted%3A+false%0Aprisma%3Aget-platform+Found+distro+info%3A%0A%7B%0A++%22targetDistro%22%3A+%22debian%22%2C%0A++%22familyDistro%22%3A+%22debian%22%2C%0A++%22originalDistro%22%3A+%22ubuntu%22%0A%7D%0Aprisma%3Aget-platform+Trying+platform-specific+paths+for+%22debian%22+%28and+%22ubuntu%22%29%0Aprisma%3Aget-platform+Found+libssl.so+file+using+platform-specific+paths%3A+libssl.so.3%0Aprisma%3Aget-platform+The+parsed+libssl+version+is%3A+3.0.x%0Aprisma%3Aclient%3Aengines%3AresolveEnginePath+enginePath+%2Fhome%2Federlima%2Fwww%2Feducation-shorts%2Fnode_modules%2F.prisma%2Fclient%2Flibquery_engine-debian-openssl-3.0.x.so.node%0Aprisma%3Aclient%3AlibraryEngine+library+starting%0Aprisma%3Aclient%3AlibraryEngine+library+started%0Aprisma%3Aclient+Prisma+Client+call%3A%0Aprisma%3Aclient+prisma.tag.upsert%28%7B%0A++where%3A+%7B%0A++++name%3A+%22Programming%22%0A++%7D%2C%0A++update%3A+%7B%7D%2C%0A++create%3A+%7B%0A++++name%3A+%22Programming%22%0A++%7D%0A%7D%29%0Aprisma%3Aclient+Generated+request%3A%0Aprisma%3Aclient+%7B%0A++%22modelName%22%3A+%22Tag%22%2C%0A++%22action%22%3A+%22upsertOne%22%2C%0A++%22query%22%3A+%7B%0A++++%22arguments%22%3A+%7B%0A++++++%22where%22%3A+%7B%0A++++++++%22name%22%3A+%22Programming%22%0A++++++%7D%2C%0A++++++%22update%22%3A+%7B%7D%2C%0A++++++%22create%22%3A+%7B%0A++++++++%22name%22%3A+%22Programming%22%0A++++++%7D%0A++++%7D%2C%0A++++%22selection%22%3A+%7B%0A++++++%22%24composites%22%3A+true%2C%0A++++++%22%24scalars%22%3A+true%0A++++%7D%0A++%7D%0A%7D%0A%0Aprisma%3Aclient%3AlibraryEngine+sending+request%2C+this.libraryStarted%3A+true%0Aprisma%3Aclient+Prisma+Client+call%3A%0Aprisma%3Aclient+prisma.tag.upsert%28%7B%0A++where%3A+%7B%0A++++name%3A+%22Web+Development%22%0A++%7D%2C%0A++update%3A+%7B%7D%2C%0A++create%3A+%7B%0A++++name%3A+%22Web+Development%22%0A++%7D%0A%7D%29%0Aprisma%3Aclient+Generated+request%3A%0Aprisma%3Aclient+%7B%0A++%22modelName%22%3A+%22Tag%22%2C%0A++%22action%22%3A+%22upsertOne%22%2C%0A++%22query%22%3A+%7B%0A++++%22arguments%22%3A+%7B%0A++++++%22where%22%3A+%7B%0A++++++++%22name%22%3A+%22Web+Development%22%0A++++++%7D%2C%0A++++++%22update%22%3A+%7B%7D%2C%0A++++++%22create%22%3A+%7B%0A++++++++%22name%22%3A+%22Web+Development%22%0A++++++%7D%0A++++%7D%2C%0A++++%22selection%22%3A+%7B%0A++++++%22%24composites%22%3A+true%2C%0A++++++%22%24scalars%22%3A+true%0A++++%7D%0A++%7D%0A%7D%0A%0Aprisma%3Aclient%3AlibraryEngine+sending+request%2C+this.libraryStarted%3A+true%0Aprisma%3Aclient+Prisma+Client+call%3A%0Aprisma%3Aclient+prisma.tag.upsert%28%7B%0A++where%3A+%7B%0A++++name%3A+%22JavaScript%22%0A++%7D%2C%0A++update%3A+%7B%7D%2C%0A++create%3A+%7B%0A++++name%3A+%22JavaScript%22%0A++%7D%0A%7D%29%0Aprisma%3Aclient+Generated+request%3A%0Aprisma%3Aclient+%7B%0A++%22modelName%22%3A+%22Tag%22%2C%0A++%22action%22%3A+%22upsertOne%22%2C%0A++%22query%22%3A+%7B%0A++++%22arguments%22%3A+%7B%0A++++++%22where%22%3A+%7B%0A++++++++%22name%22%3A+%22JavaScript%22%0A++++++%7D%2C%0A++++++%22update%22%3A+%7B%7D%2C%0A++++++%22create%22%3A+%7B%0A++++++++%22name%22%3A+%22JavaScript%22%0A++++++%7D%0A++++%7D%2C%0A++++%22selection%22%3A+%7B%0A++++++%22%24composites%22%3A+true%2C%0A++++++%22%24scalars%22%3A+true%0A++++%7D%0A++%7D%0A%7D%0A%0Aprisma%3Aclient%3AlibraryEngine+sending+request%2C+this.libraryStarted%3A+true%0A%60%60%60%0A%0A%23%23+Client+Snippet%0A%60%60%60ts%0A%2F%2F+PLEASE+FILL+YOUR+CODE+SNIPPET+HERE%0A%60%60%60%0A%0A%23%23+Schema%0A%60%60%60prisma%0A%2F%2F+PLEASE+ADD+YOUR+SCHEMA+HERE+IF+POSSIBLE%0A%60%60%60%0A%0A%23%23+Prisma+Engine+Query%0A%60%60%60%0A%7B%22X%22%3Atrue%7D%7D%7D%0A%60%60%60%0A&title=internal+error%3A+entered+unreachable+code&template=bug_report.yml

If you want the Prisma team to look into it, please open the link above 🙏
To increase the chance of success, please post your schema and a snippet of
how you used Prisma Client in the issue. 

    at ai.handleRequestError (/home/ederlima/www/education-shorts/node_modules/@prisma/client/runtime/library.js:126:7136)
    at ai.handleAndLogRequestError (/home/ederlima/www/education-shorts/node_modules/@prisma/client/runtime/library.js:126:6109)
    at ai.request (/home/ederlima/www/education-shorts/node_modules/@prisma/client/runtime/library.js:126:5817)
    at async l (/home/ederlima/www/education-shorts/node_modules/@prisma/client/runtime/library.js:131:9709)
    at async Promise.all (index 1)
    at seed (/home/ederlima/www/education-shorts/scripts/seed.ts:44:18) {
  clientVersion: '5.9.1'
}

Node.js v20.6.1
error: script "seed" exited with code 1

Environment & setup

  • OS: Ubuntu 22.04
  • Database: SQLite
  • Node.js version: 20.6.1
  • Package manager: Bun 1.0.25

Prisma Version

5.9.1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions