Skip to content

fix(prisma): stop large-team-seed running on import - #2852

Merged
dguyen merged 1 commit into
mainfrom
duncan/fix-seed-large-team-import
May 26, 2026
Merged

dguyen merged 1 commit into
mainfrom
duncan/fix-seed-large-team-import

Conversation

@ephraimduncan

Copy link
Copy Markdown
Contributor

Problem

Resetting and re-seeding the DB fails partway through medium-account-seed.ts:

PrismaClientUnknownRequestError:
Invalid `prisma.recipient.create()` invocation in
packages/prisma/seed/medium-account-seed.ts:48:30
Response from the Engine was empty

Cause

packages/prisma/seed-database.ts require()s every file in seed/ to look for a seedDatabase export. large-team-seed.ts invokes void main() at the top level, so the require() side-effect kicks off its work concurrently with the sequential seed wrapper. When large-team-seed.ts's finally block calls prisma.$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:

[SEEDING]: initial-seed.ts
[SEEDING]: Creating team with 200 organisation members...   ← from large-team-seed
[SEEDING]: medium-account-seed.ts
[SEEDING]: Creating medium account with 1000 documents...
[SEEDING]: Created 0/1000 documents...
[SEEDING]: Attaching 50 org members to the team's role group...   ← large-team-seed continuing
[SEEDING]: Done.   ← large-team-seed about to $disconnect()
...
[SEEDING]: Seed failed for medium-account-seed.ts

Fix

Guard void main() with require.main === module so large-team-seed.ts only auto-runs when invoked directly (tsx packages/prisma/seed/large-team-seed.ts), matching its documented one-off usage.

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.
@vercel

vercel Bot commented May 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stg-docs Ready Ready Preview, Comment May 21, 2026 12:55pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
prd-docs Ignored Ignored May 21, 2026 12:55pm
prd-openpage-api Ignored Ignored May 21, 2026 12:55pm

Request Review

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • coderabbit

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 71c79030-b44c-4826-818c-c9385a73f442

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch duncan/fix-seed-large-team-import

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

🚨 @ephraimduncan has 5 pull requests awaiting review. Please consider reviewing them when possible. 🚨

@dguyen
dguyen merged commit eedf483 into main May 26, 2026
11 checks passed
@dguyen
dguyen deleted the duncan/fix-seed-large-team-import branch May 26, 2026 04:13
scoobs-mystery-bytes pushed a commit to scoobs-mystery-bytes/documenso that referenced this pull request May 30, 2026

This branch was successfully deployed

1 active deployment
Preview – stg-docs — ef766f41 Deployed May 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants