@prisma/orm-postgres runtime loads the whole toolchain through family__control, so production installs carry esbuild, prettier and the CLI engine
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- bun, javascript, postgresql, typescript
- Domain
- backend, build-system, performance
Research direction
Start with dist/runtime.mjs in @prisma/orm-postgres and follow the import chain through adapter__runtime.mjs, family__control.mjs, and control-1JIbMzKB.mjs to the toolchain import. Run the Bun reproduction to confirm that @prisma/orm-postgres/runtime fails after removing @prisma/orm-toolchain. Done means the runtime no longer imports control-plane or toolchain code, a production install can load it without those packages, and relevant package/import tests pass.
Written by the indexing model from the issue text.
Description
Package and version
@prisma/[email protected], with @prisma/orm-target-postgres, @prisma/orm-family-sql and @prisma/orm-toolchain at the same version, and @prisma/[email protected].
What happened?
A production install of the PostgreSQL runtime includes the ORM toolchain and everything it brings: esbuild, prettier, vscode-languageserver, clipanion, @prisma/cli-engine and @prisma/management-api-sdk.
@prisma/orm-postgres, @prisma/orm-target-postgres and @prisma/orm-family-sql all list @prisma/orm-toolchain in dependencies, and @prisma/orm-toolchain requires @prisma/cli-engine as a peer at an exact version.
In a minimal install, this tooling is 28 MB of the 85 MB in node_modules. The application only runs queries, so none of it does any work there.
It is more than a declared dependency. Without these packages, the runtime entry does not load:
error: Cannot find module '@prisma/orm-toolchain/migration-tools/spaces'
The static import chain from the runtime entry is:
@prisma/orm-postgres/dist/runtime.mjs
@prisma/orm-target-postgres/dist/adapter__runtime.mjs
@prisma/orm-target-postgres/dist/adapter-DJoHcCZV-B6ixkVJl.mjs
@prisma/orm-target-postgres/dist/contract-contributions-DS1YZqxl-B1ZaAkPj.mjs
@prisma/orm-family-sql/dist/family__control.mjs
@prisma/orm-family-sql/dist/control-1JIbMzKB.mjs (line 30)
@prisma/orm-toolchain/migration-tools/spaces (assertDescriptorSelfConsistency)
So the runtime adapter loads the control-plane entry of the SQL family, and through it the toolchain.
What did you expect to happen?
@prisma/orm-postgres/runtime should load no control-plane code, and a production install should not need @prisma/orm-toolchain or @prisma/cli-engine.
Minimal reproduction
mkdir toolchain-in-runtime && cd toolchain-in-runtime
cat > package.json <<'JSON'
{ "private": true, "dependencies": { "@prisma/orm-postgres": "8.0.0-rc.22", "temporal-polyfill": "1.0.6", "typescript": "6.0.3" } }
JSON
bun install --production --ignore-scripts
ls node_modules/esbuild node_modules/prettier node_modules/@prisma/cli-engine
du -sm node_modules
# Remove the tooling, then load the runtime entry.
rm -rf node_modules/@prisma/orm-toolchain
bun -e "await import('@prisma/orm-postgres/runtime')"
The last command fails with the error above. node_modules is 85 MB as installed, 24 MB of which is TypeScript, the optional peer. It is 57 MB once the toolchain, @prisma/cli-engine, @prisma/management-api-sdk, esbuild, @esbuild/*, prettier, clipanion and the vscode-languageserver packages are removed.
Environment
- Bun 1.4.4 on macOS arm64 for the figures above
- Same dependency tree in our Linux production image
- PostgreSQL target,
postgres()runtime client
Additional context
#30437 describes the same root cause through @prisma/composer-prisma-cloud. Its proposed fix, publishing migration-tools in a package with no engine peer, would need to cover this path too. Moving assertDescriptorSelfConsistency out of the toolchain, or no longer importing family__control from the runtime adapter, would both remove it.
Deleting these packages from a production image is not a workaround, because the runtime entry stops loading.
— othmane.sayadi
- Dominant language
- TypeScript
- Stars
- 47.8k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 227
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from prisma/orm
-
bug/1-unconfirmed kind/bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
get-platform: distros with ID_LIKE=alpine are not detected as musl, so glibc engines are used on Alpine-based imagesPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
prisma/orm#31281 · 1 comment ·
Maintainers usually reply within 1 day
-
adapter-pg: connectToShadowDb connects to the main database when built from a connection stringMay be free again @cestercian claimed this 10 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
prisma/orm#31196 · 1 comment ·
Maintainers usually reply within 1 day
-
[Prisma 8] Type-check time grows exponentially with chained .include() callsPossibly taken @SiKreuz claimed this 13 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
prisma/orm#31161 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
prisma/orm#31125 · 4 comments · 6 reactions ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
tenstorrent/ttnn-visualizer#2526 ·
Maintainers usually reply within 1 day
-
trySessionCache calls /get-session twice when minting session_data (cache miss or expired cookie)Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
neondatabase/neon-js#301 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
tashfeenahmed/freellmapi#2305 ·
Maintainers usually reply within 1 day