neoclide / coc-tsserver

Tsserver extension for coc.nvim that provide rich features like VSCode for javascript & typescript
MIT License
1.05k stars 68 forks source link

TS Server not getting the latest version of the file, and in such a state loss can occur uppon saving (after prettier run) #378

Closed pure-bliss closed 2 years ago

pure-bliss commented 2 years ago

I don't know what exactly causes this issue, I attached a video of this to make it more easier to understand:

https://user-images.githubusercontent.com/83361786/169999181-14d2f6a3-1beb-48fd-ac65-a3f7de66b7a5.mp4

Not 100% sure if this is a coc-tsserver, coc-prettier, tsserver or coc bug, so please excuse me if I opened this issue at the wrong place, I'm not sure where to start.

This started after running :PlugUpdate and :CocUpdate yesterday. I ran yarn install --frozen-lockfile in the Coc directory to update that too.

TSServer related completition and other features are extremely unstable right now

https://user-images.githubusercontent.com/83361786/170004663-629ac46d-12a0-4f9a-879b-c704fd740eea.mp4

2022-05-24_11-57

2022-05-24_11-58

I have other issues too, which seem unrelated to this but still want to mention: tsserver-s node randomly crashes while editing the code and using its features. I haven't figured out yet how to reproduce it, but

[🡕] Process 257330 (node) of user 1000 dumped core.

Module /home/${username}/.local/share/nvm/v14.19.1/bin/node with build-id 35f0f1ca0b3a7a8e5a0e8bc6eb74d37586b00f78
Stack trace of thread 257330:
#0  0x00007f19ae67434c n/a (n/a + 0x0)
ELF object binary architecture: AMD x86-64
chemzqm commented 2 years ago

Try latest release branch of coc.nvim.

pure-bliss commented 2 years ago

Replaced the old Plug 'neoclide/coc.nvim' with Plug 'neoclide/coc.nvim', {'branch': 'release'}, and ran :PlugUpdate, but the same issues are present:

https://user-images.githubusercontent.com/83361786/170059081-5ea2ed66-6f61-4d1c-9699-c7eaa414484b.mp4

https://user-images.githubusercontent.com/83361786/170059104-0219b908-16f9-4d10-a898-cd3d7cd8c99f.mp4

chemzqm commented 2 years ago

Try minimal vimrc?

pure-bliss commented 2 years ago
~ $ cat .vimrc
let g:coc_global_extensions = [
\  'coc-tsserver',
\  'coc-eslint',
\  'coc-prettier',
\  'coc-json',
\  'coc-css'
\  ]

call plug#begin()

Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Plug 'neoclide/coc.nvim'

call plug#end()

https://user-images.githubusercontent.com/83361786/170089875-13bd66ce-b566-46ad-9f73-8f96fd1d84e0.mp4

pure-bliss commented 2 years ago

Restored coc.nvim and all coc plugins to an earlier working version

coc.nvim: 0.0.80-master (not working) -> `0.0.80-8f2a2dc441 (working)

Not working versions of plugins:

extensions/node_modules/coc-css/package.json:  "version": "1.3.0",
extensions/node_modules/coc-eslint/package.json:  "version": "1.5.8",
extensions/node_modules/coc-json/package.json:  "version": "1.4.2",
extensions/node_modules/coc-prettier/package.json:  "version": "9.3.0",
extensions/node_modules/coc-tsserver/package.json:  "version": "1.10.4",

~not~ Working version of plugins:

extensions/node_modules/coc-css/package.json:  "version": "1.3.0",
extensions/node_modules/coc-eslint/package.json:  "version": "1.5.8",
extensions/node_modules/coc-json/package.json:  "version": "1.4.2",
extensions/node_modules/coc-prettier/package.json:  "version": "1.1.24",
extensions/node_modules/coc-tsserver/package.json:  "version": "1.10.4",
extensions/node_modules/typescript/package.json:    "version": "4.6.4",

Seems like the coc-tsserver plugins version did not change between the two upgrades, and its coc-tsserver thats causing this issue. After upgrading everything but coc.nvim (with :CocUpdate everything seem to work but coc-prettier, which prints an error to :CocInfo. Maybe coc.nvim has made some changes since 8f2a2dc (2022-01-06) that breaks something for me :/

I'll just continue to use the old versions and never update again I guess.

Edit: changed which versions of plugins are working for me

chemzqm commented 2 years ago

extensions/node_modules/coc-prettier/package.json: "version": "1.1.24",

It's old version of coc-prettier. Checkout https://github.com/neoclide/coc-tsserver#troubleshooting

pure-bliss commented 2 years ago

My bad, I messed up which versions of plugins are working for me (edited in the original comment). For some reason the package.json in coc-prettier sais "version": "1.1.24". Based on that the upgraded version is 9.3.0 that should be a pretty old version 🤔 I don't remember installing a specific version, and strange that it works.

I'll try the troubleshooting tomorrow

pure-bliss commented 2 years ago

The latest coc plugins with old coc version (8f2a2dc 2022-01-06) works, but there is this error in :CocInfo:

Error on active extension coc-prettier: TypeError: "import_coc6.window.onDidChangeActiveTextEditor" is not a function

Doesn't seem to cause any issues though, must be because there is a function that the latest coc-prettier uses that is not implemented in older coc.nvim. This is gone after updating coc.nvim itself.

After updating coc.nvim the original issue I described starts happening.

tsserver output channel: tsserver.messages.txt Sorry for removing part of the paths, and the file content, the project is kinda private :/

tsserver log file is 6 MB, havent checked it yet, but I'm not sure I can post that because of the private project.

pure-bliss commented 2 years ago

Tested, and fixed by: https://github.com/neoclide/coc.nvim/commit/bb448ebb7f3a401d03e1c31407acc637e1d9a286

https://user-images.githubusercontent.com/83361786/170857114-b9848ced-78ad-4179-9529-610e5980d481.mp4

For some reason typescript still shows error for the first char of 'string', but I guess that is something else