New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4.16.1 breaks type check #19999
Comments
@darklight9811 Thanks for the report, we want to look at this, we'll attempt a reproduction, in the meantime: Which version of TypeScript are you using here? Could you try out |
This comment was marked as off-topic.
This comment was marked as off-topic.
I installed everything, rerun prisma generate and restarted ts server (vscode) |
@darklight9811 which Typescript version are you on? There was a bug in TS compiler 5.1.x that was fixed in 5.1.5. Could you try updating to 5.1.5 and see if it fixes this problem. |
@darklight9811 Prisma version Also like my colleague said, please let us know which TypeScript version you are using, |
In case it helps, I have this issue with TypeScript Edit: Ok, now Prisma Please let me know if there is something I can do to help debug!
(not sure why the engine is defaulting to openssl1.1 on Arch but no idea how to tell it to prefer 3.x) |
I cannot seem to make a simple reproduction, unfortunately. The issue seems to be very specific to how Prisma is being used, because I have two identical Nest.js projects in my monorepo, each importing Prisma from the same I have run some successful builds:
failing builds:
the rest of the projects are identical. the attached trace files can be thrown into https://ui.perfetto.dev/, and the
4.15.0-trace.json.txt - success ~4s 4.16.2-trace.json.txt - fail ~70s Can probably remove the Next.js tag since this is also happening with Nest.js (these two are too closely named lol). I wish I could be more helpful than this, but |
Just encountered the same problem, but interestingly enough, it's only happening in 4.16.2. The local build will have a memory leak until it crashes, and CI on Vercel crashes too with the same errors shared above. I've got two similar Next.js projects and only one has the problem ; each one using typescript 5.1.6. I can send you my prisma schemas if it's useful (would just prefer not doing it publicly here). |
@benjaminwaterlot Please send us your schema at schemas at prisma.io, so we can try it out, also:
Thank you! |
Hey @darklight9811 I was not able to reproduce the crash with your extension, however I did notice that the TS server freezes completely. I took your extension apart and noticed that using That said, the reported crash is probably related to something else and is schema specific, please send us your schema (you can post it here, or via a DM on our public slack, or at Detailsconst prisma = new PrismaClient().$extends({
model: {
$allModels: {
async paginate<T, const A extends Prisma.Args<T, "findMany">, R extends Prisma.Result<T, A, "findMany">, Options extends PaginationArgs<R[number]>>(
this: T, args: Omit<A, "cursor" | "skip" | "take"> & Options
) {
return {} as Promise<[
Options["map"] extends Function ? Awaited<ReturnType<Options["map"]>>[] : R,
{ page: number; pages: number; total: number; limit: number },
]>
}
}
}
})
await prisma.user.paginate({ page: 1, limit: 10, sort: "asc", order: "id" }) |
This is a great find! I am also using similar annotations in projects where Prisma is broken. I tend to extend Prisma.[model]IncludeArgs with a generic to get accurate function type outputs. I think that find narrows this down a lot. |
@TarsiSurdi @JoeyEamigh could you please share an example of what you are doing? |
@millsp Of course I can! Here is the repository for the personal project I've been developing where this bug is present: fincheck-api
The issue caused by the type annotations of the EDIT: I should clarify that the reason for the type annotations of that particular method (generics in EDIT: I've tested multiple version of TypeScript (including 5.x.x) and Node.js. The issue persists. Steps to reproduce bug
|
This appears to be exactly what I am doing as well. I am glad someone is facing this in a public repository. Thank you @TarsiSurdi! |
I look forward to getting this solved! Prisma is such a great ORM 🔥 Also, I didn't think it through but you might not even need to provide my API a database and environment variables to reproduce the issue since the server can't even compile on Prisma 4.16.x |
Having the same issue with prisma 4.16.2 and typescript 5.1.6 |
Same issue here, VSCode dies from It's probably worth noting that all of us appear to be using NestJS as well, so I'm sure that also plays a part with typing, as we cannot define types properly for extensions without proxy/factory trickery. |
Hey everyone! I have been working on a fix. Based on the reproductions of @darklight9811 and @TarsiSurdi (thanks for providing these!) I was able to come up with a fix. We want to make sure that this works for you, so could you please take a moment to try the fix/branch? I'd appreaciate if you could install |
@millsp will we have a fix for the 4.x version? It's kinda hard to test this if I need to do a major upgrade at the time time |
I could release a branch version based on 4.16.x if you want, but it is likely this fix will officially make it into v5. |
I had the same problem, and @prisma/client@5.1.0-integration-fix-client-oom-default-selection.3 fixes it for me. Thanks! |
For NestJS users: you will notice that we have a breaking change in Prisma 5, with |
prisma ver: 5.1.0-dev.55 |
@htnhan-alpha did you try with release |
@luisrudge did that work for you? |
@millsp I couldn't test it yet because I didn't find time to upgrade to v5. We just migrated from mongo+mongoose to prisma+pgsql at work 😅 so I didn't want to risk the migration with a major upgrade. I'll try to find some time next week. |
@millsp seems to be working 5.1.0-integration-fix-client-oom-default-selection.3: with v5 I get error in the |
Thanks for reporting back! |
Something pretty interesting happened...
No idea what's going on. probably a cache issue?
|
Perhaps, yes. Have you re-generated your client between each main step? |
yeah, forgot to add that to the list 😅 but it's alright. what matters is that it failed on 5.0.0 and then it got fixed with your patch. |
@millsp one thing that is still happening is that I'm not able to seems like the type returned from the |
Yes, that is expected (at least on our end), the extended clients are now fully dynamic (for performance reasons). So the type and the method are somewhat "virtual" and calculated on the spot. I am curious to know about this, why do you need to go to the definition? (asking so that I can see what can be improved). |
I want to get the actual type of the where and data. In v4, this worked: |
It happens that we have introduced helpers that do exactly this. You could do |
Thanks for your reproduction @TarsiSurdi, I can confirm that your project can now compile with the fix I have shared. |
(Maybe related #20308) |
Bug description
This will probably get dismissed because I'm not currently able to strip down from our repository what exactly is causing this. But from 4.16.0 -> 4.16.1 I'm not able to use next build because something on prisma is causing a cyclic type loop that is exhausting v8 memory.
I also noticed that types in some occasions (only happened in one model) stopped working. I can't go to type definition nor autocomplete. Don't dismiss it yet, I'm trying to reproduce what's causing this. I created this bug report in case anyone has the same issue (couldn't find others) and was able to recreate it in minimal reproduction.
Rolling back to 4.16.0 fixes this issue
An example of the error thrown while type checking:
How to reproduce
Expected behavior
No response
Prisma information
Somehow I believe the extends may have something to do with this.
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: