Repository navigation
fix(prisma): stop large-team-seed running on import - #2852
Conversation
seed-database.ts requires every file in seed/ to look for a seedDatabase export. Importing large-team-seed.ts triggered its top-level `void main()`, whose finally block disconnects the Prisma client while medium-account-seed.ts is still awaiting writes — surfacing as "Response from the Engine was empty" on prisma.recipient.create. Guard main() with `require.main === module` so it only runs when invoked directly via `tsx packages/prisma/seed/large-team-seed.ts`, matching its documented usage.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🚨 @ephraimduncan has 5 pull requests awaiting review. Please consider reviewing them when possible. 🚨 |
Problem
Resetting and re-seeding the DB fails partway through
medium-account-seed.ts:Cause
packages/prisma/seed-database.tsrequire()s every file inseed/to look for aseedDatabaseexport.large-team-seed.tsinvokesvoid main()at the top level, so the require() side-effect kicks off its work concurrently with the sequential seed wrapper. Whenlarge-team-seed.ts'sfinallyblock callsprisma.$disconnect()it closes the client mid-flight —medium-account-seed.ts's next write fails with "Response from the Engine was empty".The interleaved log proves the race:
Fix
Guard
void main()withrequire.main === modulesolarge-team-seed.tsonly auto-runs when invoked directly (tsx packages/prisma/seed/large-team-seed.ts), matching its documented one-off usage.