Prisma VSCode Plugin 2.27.0 memory leak/too many processes
Bug description
There seems to be some sort of issue with v2.27.0 of vscode plugin where if it is enabled in VScode then when running yarn dev terminal will eventually start throwing errors like below.
I believe it has something to do with prisma plugin watching files for changes.
Reverting to v2.26.0 resolves the issue.
Error 1
zsh: fork failed: resource temporarily unavailable
Error 2
yarn dev
yarn run v1.22.10
$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Loaded env from /Users/user/Development/rc/ffs-dev/.env
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
events.js:292
throw er; // Unhandled 'error' event
^
Error: spawn /usr/local/bin/node EAGAIN
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -35,
code: 'EAGAIN',
syscall: 'spawn /usr/local/bin/node',
path: '/usr/local/bin/node',
spawnargs: [
'/Users/user/Development/rc/ffs-dev/node_modules/jest-worker/build/workers/processChild.js'
]
}
error Command failed with exit code 1.
How to reproduce
Steps to reproduce the behavior:
- Open VScode
- make sure prisma 2.27.0 vscode plugin is installed
- in terminal iterm2 or any other, run project with yarn dev
- Observer errors yarn dev will crash
- try to run yarn dev again notice the following error
zsh: fork failed: resource temporarily unavailable
- try running yarn dev again Observer the error
eady - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Loaded env from /Users/user/Development/rc/ffs-dev/.env
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
events.js:292
throw er; // Unhandled 'error' event
^
Error: spawn /usr/local/bin/node EAGAIN
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -35,
code: 'EAGAIN',
syscall: 'spawn /usr/local/bin/node',
path: '/usr/local/bin/node',
spawnargs: [
'/Users/user/Development/rc/ffs-dev/node_modules/jest-worker/build/workers/processChild.js'
]
}
error Command failed with exit code 1.
- Kill vscode or install v2.26.0
- Notice that you can now run yarn dev and no issues are happening anymore
Expected behavior
Prisma information
Environment & setup
- OS: OSX Big Sur
- Editor:
Version: 1.58.2
Commit: c3f126316369cd610563c75b1b1725e0679adfb3
Date: 2021-07-14T22:09:06.581Z
Electron: 12.0.13
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Darwin x64 20.5.0
- Extension version:v2.27.0
- Vscode has no other extensions installed
Since version 3.8.0 of the Prisma VS Code extension released yesterday there is now a way to disable the File Watcher.
It's implemented as a (default = true) boolean in the settings

And can be enabled/disabled from the command palette UI like this

Could you check
- That your problem still exists with version 3.8.0 or newer
- Run the
Prisma: Disable the File Watcher functionality for Prisma Clientcommand - Did that solve the problem?
- If no, try to reload VS Code.
- If yes please let us know, it will be helpful for us.
Thank you will try!
Hi! @m3ki
I created a PR to fix the file watcher issue, I'm happy to report that on my computer (macOS m1) it's now fixed. (CPU goes from ~100% previously to 0%)
Could you confirm it's also fixed for you as well?
Follow these instructions
First, confirm that the CPU usage is high using the Prisma extension from the VS Code marketplace
- Open your project using Prisma
- If you disabled the Prisma File Watcher functionality, enable it again from the command palette:

- Open the
schema.prismafile from your project - Use "Open Process Explorer" from VS Code' menu or open the OS Activity monitor

- Note / screenshot the CPU usage for the extension host above the Prisma extension process for the explorer or for the Activity Monitor, the
Code Helper (Renderer)value and share it at the end
Second, confirm that with the new extension the CPU usage is low using a special build from my PR
Note: only the file watcher logic was changed.
- Uninstall any Prisma extension installed (uninstall is preferred as only disabling might interfere in some ways)
- Download https://github.com/prisma/language-tools/blob/artifacts/pull-request-artifacts/pr1243-prisma.vsix?raw=true
- Click "Install from VSIX" from this button (screenshot) or command palette and select the
pr1243-prisma.vsixfile
- Restart the VS Code application
- Open the
schema.prismafile from your project - Use "Open Process Explorer" from VS Code' menu or open the OS Activity monitor

- Note / screenshot the CPU usage for the extension host above the Prisma extension process for the explorer or for the Activity Monitor, the
Code Helper (Renderer)value and share it at the end
Third, if you have a TypeScript project, confirm that the file watcher works and that the types are refreshed
- Open a TypeScript file from your project where you have Prisma Client queries like
await prisma.user.findMany() - Open the
schema.prismafile from your project - Both should have no errors
- Edit the
schema.prismafile and delete all the models (only keep thedatasource&generatorblocks) - Run
npx prisma generate - In your TypeScript file, you should now instantly see a Type Error that should look like the following

- Undo the changes in your
schema.prisma - Run
npx prisma generate - The Type Error(s) in the TypeScript file should be gone now
Please share something like the following: I tested on ... (macOS m1, Windows, Linux....)
- Current extension: screenshot showing ~91% CPU (Note: CPU is only reported on the aggregated top line for some reason)

- Using
pr1243-prisma.vsix, screenshot after showing ~0% CPU usage 🎊
- The typings were updated successfully after
npx prisma generate, a Type Error was visible ✅
Thank you in advance 💚 Note: I'm waiting for some feedback before we switch to this new low CPU file watcher in a stable release on VS Code marketplace.
Will try this weekend
The fix is now in the latest 4.4.0 version on the marketplace https://marketplace.visualstudio.com/items?itemName=Prisma.prisma 🎊
For those who disabled the File Watcher functionality, you can enable it again.