neoclide/coc-tsserver

Large delays after updateOpen

ssadler opened this issue · 3 comments

Hello,

I am having an issue where after changing a file, there is a large delay before I can see type information, or commands like go to definition work.

I have looked at the server logs, which show that updateOpen is taking a long time to return:

[Trace - 10:52:41.250] <semantic> Async response received: requestCompleted (3). Request took 14625 ms

The project is not huge, however, there are a few files with some complex ish types, and I did notice that some things became slower over time when introducing them.

What I don't have is a reliable way to see what types are causing the slowdown (removing import statements is hit and miss).

I'm also not sure that the slowdown is neccesary, in the sense that the code imports causing the slowdown could be cached.

Appreciate any help!

EDIT

Typescript 5.2.2
coc-tsserver 2.1.4

Is it slow in VS Code with the same project? The log shows tsserver was slow to respond.

Havn't tried VS Code.

I seem to have found something though, using the recomended way to analyze performance hotspots:

$ npx tsc -p ./tsconfig.json --generateTrace tmpdir
$ npx analyze-trace tmpdir

So this is good news, been suffering with it for a while 🙂

Will update and close soon

Ok, got it sorted!

analyze-trace (@typescript/analyze-trace) reported the location of the performance hotspot. It was an SQL query using zapatos library, which was joining many tables. The issue was a large union type, it seems that there is some exponential complexity with union types. Refactoring it into a different module was not enough, I had to simplify the type (using Pick / Extract). Then it was fast again 🙂. Hope this helps someone!