fix: remove circular dependency in packages/prisma#24596
Merged
Conversation
- Replaced DeploymentRepository import with inline implementation - Created InlineDeploymentRepository class implementing IDeploymentRepository - Breaks circular dependency: deployment.ts -> prisma/index.ts -> usage-tracking.ts -> deployment.ts - Verified with madge: no circular dependencies found Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
💡 Enable Vercel Agent with $100 free credit for automated AI reviews |
| import { Prisma } from "@calcom/prisma/client"; | ||
| import type { PrismaClient } from "@calcom/prisma/client"; | ||
|
|
||
| class InlineDeploymentRepository implements IDeploymentRepository { |
Member
There was a problem hiding this comment.
Could we choose a better name?
I don't think inline is a product thing ?
Contributor
Author
There was a problem hiding this comment.
This is just to make clear that this dependency is Inline cause we have other implementation that isn't. This implementation is intended to be used only inside this file to avoid circular deps.
Udit-takkar
approved these changes
Oct 21, 2025
hariombalhara
approved these changes
Oct 21, 2025
keithwillcode
approved these changes
Oct 21, 2025
Contributor
E2E results are ready! |
KartikLabhshetwar
pushed a commit
to KartikLabhshetwar/cal.com
that referenced
this pull request
Oct 25, 2025
- Replaced DeploymentRepository import with inline implementation - Created InlineDeploymentRepository class implementing IDeploymentRepository - Breaks circular dependency: deployment.ts -> prisma/index.ts -> usage-tracking.ts -> deployment.ts - Verified with madge: no circular dependencies found Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
akarsh-jain-790
pushed a commit
to akarsh-jain-790/cal.com
that referenced
this pull request
Mar 8, 2026
- Replaced DeploymentRepository import with inline implementation - Created InlineDeploymentRepository class implementing IDeploymentRepository - Breaks circular dependency: deployment.ts -> prisma/index.ts -> usage-tracking.ts -> deployment.ts - Verified with madge: no circular dependencies found Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes a circular dependency in
packages/prismathat was detected using madge.Circular dependency chain (before):
Solution:
InlineDeploymentRepositoryclass withinusage-tracking.tsthat implements theIDeploymentRepositoryinterfaceDeploymentRepositorywhich was causing the circular dependencyVerification:
npx madge --circular --extensions ts,tsx packages/prismabefore: 1 circular dependency foundnpx madge --circular --extensions ts,tsx packages/prismaafter: ✔ No circular dependency found!Link to Devin run: https://app.devin.ai/sessions/1c2e0e210b464a5d877af6b3faf88bd4
Requested by: Volnei Munhoz (@volnei)
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
This is a refactoring that doesn't change runtime behavior. Testing should focus on:
npx madge --circular --extensions ts,tsx packages/prismaHuman Review Checklist
Code duplication concern: The
InlineDeploymentRepositoryduplicates logic fromDeploymentRepository. IfDeploymentRepositoryis ever updated, this inline version must be updated too. Consider adding a comment or documentation about this coupling.Verify identical behavior: Compare
InlineDeploymentRepositorymethods withDeploymentRepositoryto confirm they're functionally identical:getLicenseKeyWithId()- same query, same returngetSignatureToken()- same query, same returnConsider alternative solutions: Is inlining the best approach, or should we explore other architectural patterns to break this circular dependency?
Checklist
Summary by cubic
Removed a circular dependency in packages/prisma by inlining the deployment repository in usage-tracking.ts. The loop between deployment.ts, prisma/index.ts, and usage-tracking.ts is gone, with no behavior change.