language-tools
language-tools copied to clipboard
Prisma extension too slow
Bug description
https://github.com/user-attachments/assets/8812f241-6041-49dd-9a67-e83c7de28489
Extension work slowly. The lag came with an update of either of vscode or prisma extension at time when I was not working with prisma so I could not notice it right away. I tried previous versions of prisma from 1 year ago, 5.10.0 works fine and fast. If this is a know issue, I'd like to know some methods to cure vscode. Do you think reinstall of vscode will help?
How to reproduce
Expected behavior
No response
Prisma information
Environment & setup
vscode: 1.95.2 prisma ext: v5.22.0
Prisma Version
What are your specs and OS? Also, some extensions may interfere with Prisma extension speed and/or take up a lot of resources to work.
I encountered the same issue and discovered that it was caused by having an additional .prisma file in my project folder. Once I removed it, the performance returned to normal.
I'm having the same problem.
I tried it on ubuntu and windows and it was very slow as well.
The common thing is that it did so after I updated to the latest version.
Unlike @mod08 , I also removed the additional prisma file.
Defective Environments
Windows 10 Pro 22H2
Ubuntu 22.04.5 LTS
Are any of the other extentions slow or is vscode slow in general ? I run the exact version on a 2 vCPU server and have never seen the extension alone causing any problems.
The moment I open schema.prisma, vscode slows down rapidly.
I believe multiple .prisma files in the codebase is the source of this. Still experiencing this issue as of 6.14.0.
This isnāt just slowāit completely freezes. Because of this issue, I canāt use the Multi-File Prisma Schema feature in my VS Code environment. The editor hangs when I try to save files, making the feature basically unusable. Itās really unfortunate that such a great feature is held back by an extension performance issue. I even disabled all other extensions and tested with only this one enabled, but the behavior was the same.
Based on what Iām seeing, my guess is that the extension is traversing the entire node_modules directory to find .prisma files, which is causing the issue.
Hereās what I did:
- create multiple
prisma/models/*.prismafiles - add a
prisma.config.tsto configure the schema directory - run
prisma generate. That created.prisma/clientat this path:node_modules/.pnpm/@[email protected][email protected][email protected][email protected][email protected]/node_modules/.prisma/client/schema.prisma. - restart prisma lanaguage server or reload window.
When I restart the Prisma Language Server, Prisma-related errors show up in that file. It doesnāt seem necessary to run schema diagnostics across everything inside node_modules, though.
[Info - 4:57:45 AM] Default version of Prisma 'prisma-schema-wasm': 85179d7826409ee107a6ba334b5e305ae3fba9fb
[Info - 4:57:45 AM] Extension name @prisma/language-server with version 6.15.0
[Info - 4:57:45 AM] Prisma Engines version: 6.15.0-5.85179d7826409ee107a6ba334b5e305ae3fba9fb
[Info - 4:57:45 AM] Prisma CLI version: 6.15.0
[Info - 4:57:46 AM] Configuration changed.
running lint() from prisma-schema-wasm
running lint() from prisma-schema-wasm
running lint() from prisma-schema-wasm
running lint() from prisma-schema-wasm
...
the issue has been long gone after I updated I removed some weird conflicting extension, just saying
I think I have the same conclusion with @jinyongp. The problem is the extension is scanning node_modules for any .prisma files which is why it's so slow.
I managed to have a workaround by just explicitly defining schema.prisma
// prisma.config.ts
import path from "node:path";
import { defineConfig } from "prisma/config";
export default defineConfig({
schema: path.join("prisma", "schema.prisma"),
typedSql: {
path: path.join("prisma", "sql"),
},
});
I was previously rocking with schema: path.join("prisma"),. This works for me with the latest version 6.15.0.
@lanzclintonv
https://www.prisma.io/docs/orm/reference/prisma-config-reference#using-multi-file-schemas
Based on the documentatioć
ć
and my own experience, if you specify the schema path directly as ā schema: path.join('prisma', 'schema.prisma'), it fails to read any other ā .prisma files in prisma/models directory.
Actually, I found that the documentation is mistaken. It suggests using ā schema: path.join("prisma", "schema"), but this results in an error (ā Error: Could not load schema...) when you run ā prisma validate or prisma migrate dev.
The correct way to enable the multi-file schemas feature is to set ā schema: path.join('prisma'). This ensures the Prisma CLI works properly, even though it may cause problems for the Prisma Language Server.
@jinyongp
That's interesting. Can you keep schema: path.join('prisma', 'schema.prisma') then go to the extension's settings then set
Prisma: Schema Path to prisma/
Edit: Everything works on my end now and I think these are the modifications that I have. Multi file schemas works without issues or delays, and models inferred from different .prisma files connects properly.
Based on my tests, here are the results. Note that for all tests, I had ā "prisma.schemaPath": "prisma/" configured in my vscode settings.
| schema setting | prisma cli | prisma language server |
|---|---|---|
path.join('prisma', 'schema.prisma') |
fails to find any other ā .prisma files. |
works |
path.join('prisma', 'schema') |
triggers an ā Error: Could not load schema from '~/workspace/prisma/schema' provided by "prisma.config.ts": file or directory not found. |
works |
path.join('prisma') |
successfully finds all ā .prisma files. | stoped |
@jinyongp I just verified and you're right. The CLI doesn't infer other models correctly in my setup.
The bizarre solution for this would be putting schema.prisma under a models folder, and every other .prisma files and setting schema: path.join('prisma', 'models').
No delays and CLI works fine. I don't know about the other consequences of doing so though.
@lanzclintonv Setting ā schema: path.join('prisma', 'models') correctly locates the files within that directory, but it appears to no longer find ā prisma/schema.prisma š. This is causing the following error:
Error: Prisma schema validation - (validate wasm)
Error code: P1012
error: Native type VarChar is not supported for Default connector.
--> prisma/models/permission.prisma:4
|
3 |
4 | name String @unique @db.VarChar(30)
@jinyongp Yeah you'd have to place schema.prisma under prisma/models. I don't know if it'll have other consequences though.
I think this is an issue with how prisma.config.ts considering that it works under very specific folders but not a folder named "prisma" in general. I'll file this as an issue under the prisma orm repo.
@lanzclintonv You're right, I think this is a problem for the prisma team to handle from here. Thanks so much for your time and help!
@lanzclintonv I ran into this issue a while ago and couldnāt find a solution back then. Just tried your suggestion of moving everything under prisma/models, and it worked for me too. Thanks for sharing this workaround!