`--template nest` scaffolds NestJS 11 (CJS-style imports, no `@nestjs/cli`, tsdown build) and never closes the Prisma 8 pool on shutdown; should target NestJS 12 ESM
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, postgresql, typescript
- Ambito
- backend, build-system, tooling
Direzione di ricerca
Generate the template with the documented npm create command, then inspect package.json, tsconfig.json, src/main.ts, src/prisma/db.ts, and the Prisma module files. Run the listed Nest CLI, import, and teardown checks first. Done means the generated project targets NestJS 12, builds and tests with the Nest CLI, and cleanly closes the database pool on shutdown without breaking the documented template behavior.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
--template nest still scaffolds NestJS 11, does not install the Nest CLI, and never closes the Prisma 8 connection pool on shutdown. NestJS 12 (ESM-only) has been the current major for months and is what @nestjs/cli new produces today, so the template is the one place where "official Prisma + NestJS" and "official NestJS" disagree.
The docs page "How to use Prisma ORM with NestJS" (docs.prisma.io/docs/guides/frameworks/nestjs) sends every NestJS user to this template, so it is effectively the Prisma 8 NestJS guide.
Generated today with [email protected]:
npm create prisma@latest -- nest-ref --template nest --provider postgres --yes --skills none
What the template produces
| Aspect | Template today | Current NestJS (npx @nestjs/cli@12 new) |
|---|---|---|
@nestjs/core / common / platform-express |
^11.1.17 (resolves to 11.2.5) |
12.0.3 |
@nestjs/cli, @nestjs/schematics, @nestjs/testing |
not installed | installed; nest build, nest g resource, nest start --watch all work |
| Module system | "type": "module" but every relative import is extensionless (from "./app.module"), i.e. CommonJS spelling |
ESM with .js extensions (from './app.module.js'), module: nodenext |
| Build | tsdown bundling to dist/server.mjs, with a custom externals list for optional Nest peer deps |
nest build (tsc), dist/main.js |
| Dev loop | tsx watch src/main.ts |
nest start --watch |
| Tests | none | vitest unit + e2e scaffolded |
| TypeScript | ^5.9.3 |
^6.0.2 |
| Pool teardown | none (db.close() never called, no enableShutdownHooks) |
n/a |
| Extra deps | @prisma/composer, @prisma/composer-prisma-cloud, alchemy (Cloudflare runtime), @prisma/dev |
none |
Notes on the rows that matter most:
-
NestJS 11 vs 12. The generated
package.jsonpins^11.1.17, so a user who scaffolds today and later runsnest gfrom a globally installed Nest 12 CLI gets schematics that emit.js-suffixed ESM imports into a project whose existing files are extensionless.npx --no-install nest buildfails in the generated project (could not determine executable to run) because@nestjs/cliis not a dependency. -
Extensionless imports only work because of tsdown. With
"type": "module"inpackage.json,import { AppModule } from "./app.module"is not valid for Node; it works here only because tsdown resolves and bundles it. The moment someone swaps the build fortsc/nest build(the standard Nest workflow), every import breaks. NestJS 12 avoids this by spelling.jseverywhere; the template should too. -
No
db.close()on shutdown.src/prisma/db.tsexports a long-livedpostgres<Contract>(...)client andPrismaServicejust wraps it (readonly db = db). Nothing implementsOnApplicationShutdown, andmain.tsnever callsapp.enableShutdownHooks(), so a SIGTERM under a process manager or in a container leaves thepg.Poolto be killed rather than drained. The Prisma 8 runtime reference (references/runtime.md) is explicit that servers must close exactly once, on shutdown. This is the one NestJS-specific thing a template has to get right, since Prisma 7 users are used toenableShutdownHooks/$disconnectand will look for the equivalent. -
Composer/Alchemy weight. The nest template pulls in
@prisma/composer,@prisma/composer-prisma-cloudand[email protected](which brings the Cloudflare runtime) into a plain Node/Express server. That is fine as an opt-in, but it makes the scaffold a poor starting point for the majority of Nest users who deploy to their own infrastructure, and it is why install takes minutes on a cold cache. Related: #101 (ORM pin vsprisma@latestmismatch window) shows how sensitive the template's dependency block is; fewer moving parts would help there too.
What I expected
A NestJS template that is a superset of npx @nestjs/cli@latest new, so the Nest CLI, schematics, and build all keep working:
-
@nestjs/*at^12, plus@nestjs/cli,@nestjs/schematics,@nestjs/testingindevDependencies. -
tsconfig.jsonwithmodule: "nodenext"/moduleResolution: "nodenext"(Nest 12 default) and relative imports spelled with.js. This currently requiresdb.tsto import./contract.jsrather than./contract.d; that is tracked in prisma/orm#30358, and the template can just use the working spelling. -
"build": "nest build","prebuild": "prisma contract emit","start:dev": "nest start --watch","start:prod": "node dist/main". Keeptsdownonly if a single-file bundle is needed for Composer deploys, as a separatebuild:composerscript. -
A
PrismaModulethat owns the lifecycle. Either of these is fine; I verified the first one end to end (build, unit + e2e tests, CRUD routes,db.transaction, clean exit on SIGTERM) on Nest 12.0.3 +@prisma/[email protected]:// src/prisma/prisma.module.ts import { Global, Module, type OnApplicationShutdown } from '@nestjs/common'; import { db } from './db.js'; export const DB = Symbol('PRISMA_DB'); export type Db = typeof db; @Global() @Module({ providers: [{ provide: DB, useValue: db }], exports: [DB] }) export class PrismaModule implements OnApplicationShutdown { async onApplicationShutdown() { await db.close(); } }// src/main.ts const app = await NestFactory.create(AppModule); app.enableShutdownHooks(); await app.listen(process.env.PORT ?? 3000);or keep the current
PrismaService { readonly db = db }class and addimplements OnApplicationShutdown { onApplicationShutdown() { return db.close(); } }plusenableShutdownHooks(). -
Composer/Alchemy deps behind a flag (
--deployalready exists) rather than in the base template.
Reproduction
npm create prisma@latest -- nest-ref --template nest --provider postgres --yes --skills none
cd nest-ref
npm ls @nestjs/core # 11.2.5
npm view @nestjs/core version # 12.0.3
npx --no-install nest build # npm error could not determine executable to run
grep -n 'from "./' src/*.ts # extensionless imports in a "type": "module" package
grep -rn 'close\|enableShutdownHooks\|OnApplicationShutdown' src/ || echo "no teardown"
Environment: [email protected], Node 24.11.1, npm 11.6.2, macOS 15.6. Generated package.json resolves to @nestjs/[email protected], @prisma/[email protected], [email protected], [email protected], [email protected].
Related
- prisma/orm#30359: request for a documented NestJS integration pattern /
@prisma/orm-nestjs. If that lands, this template should use it. - prisma/orm#30358:
orm initrewritesnodenexttsconfigs becausedb.tsimports./contract.d. - #107:
--skip-install, which would have made inspecting this template much cheaper.
- Lingua principale
- TypeScript
- Stelle
- 12
- Fork
- 0
- Merge medio
- 43m
- PR unite (30g)
- 8
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di prisma/create-prisma
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
prisma/create-prisma#112 ·
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
prisma/create-prisma#107 ·
Tutte le issue di prisma/create-prisma
Issue simili
-
dream report: normalizeMutation discards ok/status, consumers can only string-match the summaryAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
thecodacus/understory#61 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
Termix-SSH/Plugin-Hosts-Config#14 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
-
ai-generated priority: p2 size: s type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
JonathanTSilva/jts-website#92 ·
I maintainer di solito rispondono entro 1 giorno
-
Toast announcer reads a doubled period when a toast's title ends in punctuationForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
vercel-labs/ui#999 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
ehmpathy/rhachet-roles-ehmpathy#1443 ·
I maintainer di solito rispondono entro 1 giorno