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

D1_ERROR: Expression tree is too large (maximum depth 100) #23919

Open
hrueger opened this issue Apr 22, 2024 · 1 comment
Open

D1_ERROR: Expression tree is too large (maximum depth 100) #23919

hrueger opened this issue Apr 22, 2024 · 1 comment
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: chunking topic: d1 Issues related to Cloudflare D1 topic: driverAdapters topic: @prisma/adapter-d1

Comments

@hrueger
Copy link

hrueger commented Apr 22, 2024

Bug description

When using connect: string[] in an update or create query and connecting more than 100 items, it breaks when using Cloudflare D1. The error message is:

[backend] prisma:query -- Implicit "ROLLBACK" query via underlying driver
[backend] PrismaClientUnknownRequestError: 
[backend] Invalid `prisma.onlinePayout.create()` invocation:
[backend] 
[backend] 
[backend] Error occurred during query execution:
[backend] ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(SqliteError { extended_code: 1, message: Some("D1_ERROR: Expression tree is too large (maximum depth 100)") }), transient: false })
[backend]     at In.handleRequestError (/Users/hannes/source/redacted/node_modules/@prisma/client/runtime/library.js:122:7044)
[backend]     at In.handleAndLogRequestError (/Users/hannes/source/redacted/node_modules/@prisma/client/runtime/library.js:122:6188)
[backend]     at In.request (/Users/hannes/source/redacted/node_modules/@prisma/client/runtime/library.js:122:5896)
[backend]     at async l (/Users/hannes/source/redacted/node_modules/@prisma/client/runtime/library.js:127:11167)
[backend]     at async payoutNow (/Users/hannes/source/redacted/packages/backend/src/routes/(admin)/series/[series]/editions/[edition]/billing/+page.server.ts:120:30)
[backend]     at async Module.handle_action_json_request (/Users/hannes/source/redacted/node_modules/@sveltejs/kit/src/runtime/server/page/actions.js:51:16)
[backend]     at async resolve (/Users/hannes/source/redacted/node_modules/@sveltejs/kit/src/runtime/server/respond.js:446:18)
[backend]     at async eval (/Users/hannes/source/redacted/packages/_lib/server/logging.server.ts:28:22)
[backend]     at async Module.respond (/Users/hannes/source/redacted/node_modules/@sveltejs/kit/src/runtime/server/respond.js:319:20)
[backend]     at async file:///Users/hannes/source/redacted/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:524:22 {
[backend]   clientVersion: '5.12.1'
[backend] }

Here's the full sql query being generated:

prisma:query UPDATE `main`.`Order` SET `onlinePayoutId` = ?, `updatedAt` = ? WHERE ((`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1) OR (`main`.`Order`.`id` = ? AND 1=1))

How to reproduce

Connect more than 100 items in a relation when using the D1 adapter.

Expected behavior

It works fine and does not throw any error.

Prisma information

model Order {
  @@index([id])
  id              String        @id @default(uuid())
  amount          Int
  onlinePayout    OnlinePayout? @relation(fields: [onlinePayoutId], references: [id])
  onlinePayoutId  String?
}

model OnlinePayout {
  @@index([id])
  id     String @id @default(uuid())
  orders Order[]
}
const onlinePayout = await prisma.onlinePayout.create({
  data: {
      amount,
      orders: {
          connect: orders.map((order) => ({ id: order.id })),
      },
  },
  include: {
      orders: true
  }
});

Environment & setup

  • OS: MacOS
  • Database: Cloudflare D1
  • Node.js version: 23.6.1

Prisma Version

prisma                  : 5.12.1
@prisma/client          : 5.12.1
Computed binaryTarget   : darwin-arm64
Operating System        : darwin
Architecture            : arm64
Node.js                 : v21.6.1
Query Engine (Node-API) : libquery-engine 473ed3124229e22d881cb7addf559799debae1ab (at ../../node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Schema Engine           : schema-engine-cli 473ed3124229e22d881cb7addf559799debae1ab (at ../../node_modules/@prisma/engines/schema-engine-darwin-arm64)
Schema Wasm             : @prisma/prisma-schema-wasm 5.12.0-21.473ed3124229e22d881cb7addf559799debae1ab
Default Engines Hash    : 473ed3124229e22d881cb7addf559799debae1ab
Studio                  : 0.499.0
@hrueger hrueger added the kind/bug A reported bug. label Apr 22, 2024
@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. team/client Issue for team Client. topic: @prisma/adapter-d1 topic: d1 Issues related to Cloudflare D1 topic: driverAdapters topic: chunking 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 Apr 23, 2024
@janpio
Copy link
Member

janpio commented Apr 26, 2024

Can reproduce:
image

prisma:query -- Implicit "BEGIN" query via underlying driver
prisma:query INSERT INTO `main`.`User` (`email`, `name`) VALUES (?,?) RETURNING `id` AS `id`
prisma:query UPDATE `main`.`Post` SET `authorId` = ? WHERE ((`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1) OR (`main`.`Post`.`id` = ? AND 1=1))
prisma:query -- Implicit "ROLLBACK" query via underlying driver
prisma:error 
Invalid `prisma.user.create()` invocation:


Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(SqliteError { extended_code: 1, message: Some("D1_ERROR: Expression tree is too large (maximum depth 100)") }), transient: false })
✘ [ERROR] Error in performIO: Error: D1_ERROR: Expression tree is too large (maximum depth 100)

      at D1Database._sendOrThrow (cloudflare-internal:d1-api:66:19)
      at async D1PreparedStatement.run (cloudflare-internal:d1-api:178:29)
      ... 2 lines matching cause stack trace ...
      at null.<anonymous> (async
  file:///workspace/prisma-d1-variables-bug/.wrangler/tmp/dev-iVxUPq/index.js:1703:18) {
    [cause]: Error: Expression tree is too large (maximum depth 100)
        at D1Database._sendOrThrow (cloudflare-internal:d1-api:67:24)
        at async D1PreparedStatement.run (cloudflare-internal:d1-api:178:29)
        at async D1Transaction.performIO
  (file:///workspace/prisma-d1-variables-bug/node_modules/@prisma/adapter-d1/dist/index.mjs:233:19)
        at async D1Transaction.executeRaw
  (file:///workspace/prisma-d1-variables-bug/node_modules/@prisma/adapter-d1/dist/index.mjs:225:17)
        at null.<anonymous> (async
  file:///workspace/prisma-d1-variables-bug/.wrangler/tmp/dev-iVxUPq/index.js:1703:18)
  }


[wrangler:err] PrismaClientUnknownRequestError: 
Invalid `prisma.user.create()` invocation:


Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(SqliteError { extended_code: 1, message: Some("D1_ERROR: Expression tree is too large (maximum depth 100)") }), transient: false })
    at or.handleRequestError (file:///workspace/prisma-d1-variables-bug/node_modules/@prisma/client/runtime/wasm.js:22:7318)
    at or.handleAndLogRequestError (file:///workspace/prisma-d1-variables-bug/node_modules/@prisma/client/runtime/wasm.js:22:6462)
    at or.request (file:///workspace/prisma-d1-variables-bug/node_modules/@prisma/client/runtime/wasm.js:22:6176)
    at async f (file:///workspace/prisma-d1-variables-bug/node_modules/@prisma/client/runtime/wasm.js:27:11094)
    at async Object.fetch (file:///workspace/prisma-d1-variables-bug/src/index.ts:23:17)
    at async jsonError (file:///workspace/prisma-d1-variables-bug/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:10)
    at async drainBody (file:///workspace/prisma-d1-variables-bug/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts:5:10)
[wrangler:inf] GET / 500 Internal Server Error (1346ms)

The query triggering the failure here seems to be the one for the connect in the Prisma Client query.
We need to chunk this query as well.

See full reproduction: https://github.com/janpio/prisma-d1-variables-bug/tree/janpio/23919 (Based on reproduction from #23743)

@Weakky Weakky self-assigned this Apr 29, 2024
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: chunking topic: d1 Issues related to Cloudflare D1 topic: driverAdapters topic: @prisma/adapter-d1
Projects
None yet
Development

No branches or pull requests

3 participants