From ea53316d3bbdef326ee727a4ca749f1eee48d1d6 Mon Sep 17 00:00:00 2001 From: willbot Date: Tue, 22 Sep 2026 12:00:13 +0200 Subject: [PATCH 1/2] docs(guides): close the client with db.close(), not db.runtime().close() Ten guides and the guide-writing page closed the client with `db.runtime().close()`. The reference says `db.close()`, and the source agrees: `db.close()` marks the client closed, waits for a pending connect, and ends the pool it owns, while `runtime.close()` only closes the driver and leaves the client looking open, so a later query fails with a pool error instead of `DRIVER.NOT_CONNECTED`. Co-Authored-By: Claude Fable 5.1 Signed-off-by: willbot Signed-off-by: Will Madden --- apps/docs/content/docs/guides/database/data-migration.mdx | 4 ++-- .../content/docs/guides/database/multiple-databases.mdx | 6 +++--- .../content/docs/guides/deployment/bun-workspaces.mdx | 8 ++++---- apps/docs/content/docs/guides/deployment/docker.mdx | 2 +- .../content/docs/guides/deployment/pnpm-workspaces.mdx | 6 +++--- apps/docs/content/docs/guides/deployment/turborepo.mdx | 4 ++-- apps/docs/content/docs/guides/frameworks/solid-start.mdx | 6 +++--- apps/docs/content/docs/guides/integrations/ai-sdk.mdx | 2 +- apps/docs/content/docs/guides/making-guides.mdx | 2 +- .../docs/guides/switch-to-prisma-orm/from-drizzle.mdx | 2 +- .../docs/guides/switch-to-prisma-orm/from-sql-orms.mdx | 6 +++--- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/apps/docs/content/docs/guides/database/data-migration.mdx b/apps/docs/content/docs/guides/database/data-migration.mdx index 2900cbb8db..ee364d250b 100644 --- a/apps/docs/content/docs/guides/database/data-migration.mdx +++ b/apps/docs/content/docs/guides/database/data-migration.mdx @@ -113,7 +113,7 @@ await db.orm.public.Post.create({ title: "Release notes", content: "v1.0", publi const posts = await db.orm.public.Post.select("id", "title", "published").all(); console.log(posts); -await db.runtime().close(); +await db.close(); ``` ```bash @@ -325,7 +325,7 @@ const posts = await db.orm.public.Post .all(); console.log(posts); -await db.runtime().close(); +await db.close(); ``` ```bash diff --git a/apps/docs/content/docs/guides/database/multiple-databases.mdx b/apps/docs/content/docs/guides/database/multiple-databases.mdx index b0cf85f5a0..d2ebcc0bc4 100644 --- a/apps/docs/content/docs/guides/database/multiple-databases.mdx +++ b/apps/docs/content/docs/guides/database/multiple-databases.mdx @@ -322,8 +322,8 @@ async function main() { }); console.log("Seeded", alice.email, "and", bob.email, "with one post each."); - await usersDb.runtime().close(); - await postsDb.runtime().close(); + await usersDb.close(); + await postsDb.close(); } main().catch((error) => { @@ -467,7 +467,7 @@ Commands without `--config` fail once the default config is gone. Running `npx p - **No relations across databases.** A contract covers one database. Keep a plain id column such as `authorId` on the side that references the other database, and join in application code. - **`npx prisma@latest init` writes a third config.** It creates a `prisma.config.ts` that holds only the `skills` section for agent skills. That is expected; the database commands keep using `--config` with the two database configs. -- **Do not close a client per request.** In `page.tsx` and route handlers, never call `usersDb.runtime().close()`. The pools are shared across requests and close when the process exits. Only scripts such as `prisma/seed.ts` close them. +- **Do not close a client per request.** In `page.tsx` and route handlers, never call `usersDb.close()`. The pools are shared across requests and close when the process exits. Only scripts such as `prisma/seed.ts` close them. - **`orm init` picks the package manager from your lockfile.** Run it after `create-next-app` has written `package-lock.json`, `pnpm-lock.yaml`, or `bun.lock`, or it may install with a different package manager than the one you use. ## Prompt your coding agent diff --git a/apps/docs/content/docs/guides/deployment/bun-workspaces.mdx b/apps/docs/content/docs/guides/deployment/bun-workspaces.mdx index 745a5a7dfe..9fcd8c0a72 100644 --- a/apps/docs/content/docs/guides/deployment/bun-workspaces.mdx +++ b/apps/docs/content/docs/guides/deployment/bun-workspaces.mdx @@ -37,7 +37,7 @@ Create a Bun workspaces monorepo with a shared Prisma ORM database package and a 1. Create `my-monorepo` with a root `package.json` that sets `"workspaces": ["apps/*", "packages/*"]`, then create `apps/` and `packages/database/`. Give `packages/database` a `package.json` with `"name": "database"`, `"private": true`, `"type": "module"` and `"main": "index.ts"`. 2. In `packages/database`, run `bunx prisma@latest orm init --yes --target postgres --authoring psl`. Then run `bunx prisma@latest init` there so the Prisma agent skills are installed and stay current, and use them. Get a database connection string: use the one I give you, or create a Prisma Postgres database with `bunx create-db@latest` and show me the claim URL it prints. Write it as `DATABASE_URL` into `packages/database/.env`. 3. Add package scripts to `packages/database`: `db:init` (`prisma db init`), `db:update` (`prisma db update`), `db:seed` (`bun src/prisma/seed.ts`). Run `bun run db:init` there. -4. Create `packages/database/index.ts` that re-exports `db` from `./src/prisma/db`, and `packages/database/src/prisma/seed.ts` that upserts three users with `db.orm.public.User.upsert({ create, update: {}, conflictOn: { email } })` and ends with `await db.runtime().close()`, following https://www.prisma.io/docs/guides/deployment/bun-workspaces.md. Run `bun run db:seed`. +4. Create `packages/database/index.ts` that re-exports `db` from `./src/prisma/db`, and `packages/database/src/prisma/seed.ts` that upserts three users with `db.orm.public.User.upsert({ create, update: {}, conflictOn: { email } })` and ends with `await db.close()`, following https://www.prisma.io/docs/guides/deployment/bun-workspaces.md. Run `bun run db:seed`. 5. Add root scripts `dev`, `build`, `start`, `db:init`, `db:update` and `seed` that use `bun run --filter