question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mongoose slows down performance of VSCode (TSServer) by a lot

See original GitHub issue

Do you want to request a feature or report a bug?

bug

What is the current behavior?

It slows down vscode by a lot, even with small projects. I have a very small project, with like 2 small schemas, and the 2 other files, containing on average 160 lines of code, and vscode slows down a lot as soon as I install mongoose. This does not happen when I install most other libraries (haven’t tested them all lmao). If I uninstall mongoose, it comes back and works perfectly normal. To clarify “slowing down” means that typescript language server needs 3-5 seconds to realise that I’m importing somethign invalid, and just vscode in general to realise I’m importing something that’s never used takes around 2-4 seconds. Usually it happens in under a second so like… you know… And it’s not like vscode is taking a lot of ram/cpu either, it just grows slow. Btw I think this is a mongoose issue, since it happens with no other library, its a special case here Reloading typescript server or project doesn’t help

If the current behavior is a bug, please provide the steps to reproduce.

Have vscode to edit your code Install mongoose on your current project (npm i mongoose

My tsconfig.json:

{
    "compilerOptions": {
        "allowJs": true,
        "moduleResolution": "Node",
        "esModuleInterop": true,
        "target": "ES6",
        "resolveJsonModule": true,
        "outDir": "./dist",
        "checkJs": true,
        "module": "CommonJS",
        "lib": ["ESNext"]
    },
    "include": ["src"]
}

What is the expected behavior?

It to not be like this, lmao.

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that “latest” is not a version.

Node: v16.2.0 Mongoose: 5.12.13 Linux: 5.12.7-arch1-1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:72
  • Comments:217 (51 by maintainers)

github_iconTop GitHub Comments

38reactions
Thisura98commented, Jul 23, 2021

Decided to give it one more shot by taking into consideration feedback by @TigranAvagyan18. And I got it to work!

Commands:

npm i mongoose@5.10.19 --save
npm i @types/mongoose@5.10.5 --save

Summary:

  • Downgrade to last version before Mongoose’s own TS types
  • Install DefinitelyTyped’s Mongoose types.

My existing code worked with these versions without issues. Code completion performance is also back! It feels so good to have the snappy completion back.

As a side note, Mongoose introduced their own types in version 5.11.0 according to this. 5.10.19 was the last version released before that according to this

I will test some more tonight to see if my current code was affected by this downgrade and update this post if I find any.

23reactions
nikolaninkovninkovcommented, Jul 19, 2021

This really needs a fix… Programming is not possible like this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mongoose with TypesScript slows down VSCode code ...
I had the same issue and it seems it is a known problem with mongoose 5. This answer helped me to solve it...
Read more >
Vasyl Boroviak on Twitter: "For those who are interested in seeing ...
It's not yet fixed for mongoose v5 though. Still slowing down devs. github.com. Mongoose slows down performance of VSCode (TSServer) by a lot...
Read more >
Mongo Snippets for Node-js - Visual Studio Marketplace
Extension for Visual Studio Code - Provides snippets, boilerplate code for Mongo queries and completion suggestions for mongoose models.
Read more >
Speed Up TypeScript in VSCode in 1 Minute | by Dmitry Borody
We all know how TypeScript can get slow in VS Code. ... This quickly gets frustrating, slowing down your feedback loops (and fast...
Read more >
Untitled
Pent coat 2016, Patrick dezart, Aydas alquiler, Loteria de pocitos software, Orata di mare ricetta, Vader down checklist, Vedlik a pulikutya zippy, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found