Skip to content

Query compiler wraps single-statement updateMany/createMany in an internal transaction, breaking transaction-less adapters (PrismaNeonHttp) #29748

Closed
prisma/prisma-engines
#5840

Description

@gordyf

Bug description

The Prisma 7 query compiler wraps updateMany and createMany in an internal interactive transaction even though both operations compile to exactly one SQL statement. On driver adapters that don't support transactions — notably PrismaNeonHttp, whose startTransaction intentionally rejects — every updateMany/createMany call therefore throws:

Error: Transactions are not supported in HTTP mode
    at PrismaNeonHttpAdapter.startTransaction
    at #r (...)
    at async ar.startInternalTransaction
    at async e.interpretNode
    at async e.run
    at async e.execute
    at async lr.request
    at async Object.singleLoader

A single statement is inherently atomic, so the transaction wrapper adds nothing on any backend — and it makes two core write operations unusable on the documented Neon HTTP adapter configuration.

Tested operation matrix (identical on 7.8.0 and 7.9.0, Postgres provider), using a stub driver adapter that records whether startTransaction is requested:

Operation Requests transaction Statements inside
findMany / findUnique / count no —
create no —
update no —
delete / deleteMany no —
createManyAndReturn no —
upsert (non-empty update) no —
updateMany yes 1 (UPDATE ... WHERE ...)
createMany (with or without skipDuplicates) yes 1 (INSERT ... [ON CONFLICT DO NOTHING])
upsert (empty update: {}) yes 2 (SELECT then INSERT)

The deleteMany/updateMany asymmetry makes the transaction wrapper look unintentional: deleteMany executes its single DELETE directly on the adapter, while the structurally identical updateMany goes through startInternalTransaction.

(The empty-update upsert case is genuinely multi-statement, so a transaction there is at least coherent — listed only for completeness. This report is about the single-statement operations.)

Trace of what actually happens inside the transaction for updateMany, from a stub adapter with usePhantomQuery: true:

[startTransaction]
[tx executeRaw] UPDATE "public"."User" SET "welcomeEmailSentAt" = $1 WHERE ("public"."User"."id" = $2 AND "public"."User"."welcomeEmailSentAt" IS NULL)
[commit]

One statement in, commit, done — the transaction machinery is pure overhead, and a hard failure on transaction-less adapters.

Real-world impact

We migrated a production Cloudflare Workers app (SvelteKit + Neon) to Prisma 7 using PrismaNeonHttp for regular queries, per the Neon serverless driver docs (HTTP mode keeps the Worker stateless and lets the Neon compute scale to zero). After the migration, every one of our ~19 updateMany/createMany call sites returned 500 — including the post-purchase endpoint of a paid product, which failed for every new customer until we diagnosed it.

Expected behavior

Single-statement plans should execute directly against the adapter (as deleteMany, update, and create already do), without requesting startTransaction. Alternatively, the query interpreter could skip the transaction wrapper when the adapter reports transactions unsupported and the plan contains exactly one statement — auto-commit of one statement is semantically identical to BEGIN; stmt; COMMIT.

Reproduction

Schema:

model User {
  id   Int     @id
  name String?
}

Script (any Neon database URL, or Neon's serverless protocol via the local-neon-http-proxy docker image in front of a local Postgres):

import { PrismaNeonHttp } from '@prisma/adapter-neon';
import { PrismaClient } from './generated/client.js';

const db = new PrismaClient({ adapter: new PrismaNeonHttp(process.env.DATABASE_URL, {}) });

await db.user.deleteMany({ where: { id: 1 } }); // works — no transaction requested
await db.user.updateMany({ where: { id: 1 }, data: { name: 'x' } });
// Error: Transactions are not supported in HTTP mode
//     at PrismaNeonHttpAdapter.startTransaction

await db.user.createMany({ data: [{ id: 2 }] });
// same error

To confirm the transaction wrapper (and its single-statement content) without a database, pass a minimal stub adapter and log startTransaction/executeRaw calls — the plan for updateMany requests a transaction, executes exactly one UPDATE, then commits.

Workaround

We currently patch @prisma/adapter-neon so PrismaNeonHttpAdapter.startTransaction returns a single-statement pseudo-transaction (usePhantomQuery: true; the one statement passes straight through to the auto-committing HTTP client; a second statement rejects loudly so genuinely multi-statement transactions can't silently lose atomicity). That restores updateMany/createMany while keeping nested writes / $transaction failing as documented — but it's a patch we'd rather not carry.

Found while investigating the same migration as #29743.

Severity

🚨 Critical: Data loss, app crash, security issue

(Every updateMany/createMany call throws on the documented Neon HTTP adapter setup — hard runtime failure of core write operations.)

Environment & setup

  • OS: Cloudflare Workers (also reproduced on macOS / Node 22)
  • Database: Neon Postgres 17, @neondatabase/serverless HTTP transport
  • Node.js version: n/a (workerd) / 22.x locally
  • Generator: prisma-client with runtime = "cloudflare" (also reproduced with runtime = "nodejs")

Prisma Version

7.8.0 (also reproduced on 7.9.0)
@prisma/client        7.8.0
@prisma/adapter-neon  7.8.0

Activity

  1. added a commit that references this issue on Jul 27, 2026
    9d90ce2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions