language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Prisma extension too slow

Open piscopancer opened this issue 1 year ago • 5 comments

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

piscopancer avatar Nov 14 '24 20:11 piscopancer

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.

incandesc3nce avatar Nov 15 '24 08:11 incandesc3nce

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.

mod08 avatar Nov 26 '24 07:11 mod08

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

ro80t avatar Dec 03 '24 07:12 ro80t

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.

AnimeshRy avatar Feb 11 '25 12:02 AnimeshRy

The moment I open schema.prisma, vscode slows down rapidly.

ro80t avatar Jun 02 '25 00:06 ro80t

I believe multiple .prisma files in the codebase is the source of this. Still experiencing this issue as of 6.14.0.

lanzclintonv avatar Aug 26 '25 01:08 lanzclintonv

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:

  1. create multiple prisma/models/*.prisma files
  2. add a prisma.config.ts to configure the schema directory
  3. run prisma generate. That created .prisma/client at this path: node_modules/.pnpm/@[email protected][email protected][email protected][email protected][email protected]/node_modules/.prisma/client/schema.prisma.
  4. 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.

Image
[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
...

jinyongp avatar Aug 27 '25 19:08 jinyongp

the issue has been long gone after I updated I removed some weird conflicting extension, just saying

piscopancer avatar Aug 30 '25 22:08 piscopancer

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 avatar Sep 01 '25 02:09 lanzclintonv

@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 avatar Sep 01 '25 02:09 jinyongp

@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/

Image

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.

lanzclintonv avatar Sep 01 '25 02:09 lanzclintonv

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 avatar Sep 01 '25 03:09 jinyongp

@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 avatar Sep 01 '25 03:09 lanzclintonv

@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 avatar Sep 01 '25 04:09 jinyongp

@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 avatar Sep 01 '25 04:09 lanzclintonv

@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!

jinyongp avatar Sep 01 '25 04:09 jinyongp

@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!

amitjans avatar Sep 16 '25 23:09 amitjans