docs(errors): document mongoose.model() init-order time bomb in standalone scripts#3795
Conversation
…alone scripts Closes #3789
|
Warning Review limit reached
More reviews will be available in 1 minute and 12 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ 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 |
There was a problem hiding this comment.
Pull request overview
Adds a new entry to ERRORS.md documenting an ESM init-order pitfall where top-level mongoose.model() lookups in repository modules can crash standalone scripts (crons/migrations) with MissingSchemaError when models haven’t been registered yet.
Changes:
- Appends a one-line ERRORS.md entry describing the
mongoose.model()import-time evaluation hazard in standalone scripts, why tests may miss it, and the two recommended mitigation patterns (lazy model getter or dynamic import afterloadModels()).
Summary
ERRORS.mddocumenting theMissingSchemaErrorinit-order time bomb triggered when a repository uses top-levelmongoose.model()and is imported from a standalone script (cron, migration) beforeloadModels()runs.Closes #3789
Test plan
ERRORS.mdone-liner format.