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

Events are either not traced or not processed properly #430

Closed resolritter closed 1 year ago

resolritter commented 1 year ago

I'm noticing that sometimes, when I do many edits in a quick succession, the server does not generate the diagnostics as I am expecting. It appears that the diagnostics are lost or not reported correctly. This might have something to do with the events not being processed in the right order, as I'll describe below.

I have the following settings in coc-settings.json:

  "tsserver.log": "verbose",
  "tsserver.trace.server": "verbose",

I was editing a TypeScript file like this:

console. // <- cursor after '.'

[EDIT 1] Then I typed:

console.d // <- cursor after 'd'

[EDIT 2] Then I typed:

console.di // <- cursor after 'i'

The diagnostic events for EDIT 1 appeared after the diagnostic events for EDIT 2 in the logs:

``` [Trace - 1:55:24 PM] Event received: semanticDiag (0). Data: { "file": "/home/user/new.ts", "diagnostics": [ { "start": { "line": 3, "offset": 9 }, "end": { "line": 3, "offset": 11 }, "text": "Property 'di' does not exist on type 'Console'.", "code": 2339, "category": "error" } ] } [Trace - 1:55:24 PM] Event received: suggestionDiag (0). Data: { "file": "/home/user/new.ts", "diagnostics": [] } [Trace - 1:55:24 PM] Async response received: requestCompleted (154). Request took 8 ms. [Trace - 1:55:26 PM] Sending request: updateOpen (155). Response expected: yes. Current queue length: 0 Arguments: { "changedFiles": [ { "fileName": "/home/user/new.ts", "textChanges": [ { "newText": "", "start": { "line": 3, "offset": 10 }, "end": { "line": 3, "offset": 11 } } ] } ], "closedFiles": [], "openFiles": [] } [Trace - 1:55:26 PM] Response received: updateOpen (155). Request took 1 ms. Success: true Result: true [Trace - 1:55:26 PM] Sending request: geterr (156). Response expected: yes. Current queue length: 0 Arguments: { "delay": 0, "files": [ "/home/user/new.ts" ] } [Trace - 1:55:26 PM] Event received: syntaxDiag (0). Data: { "file": "/home/user/new.ts", "diagnostics": [] } [Trace - 1:55:26 PM] Event received: semanticDiag (0). Data: { "file": "/home/user/new.ts", "diagnostics": [ { "start": { "line": 3, "offset": 9 }, "end": { "line": 3, "offset": 10 }, "text": "Property 'd' does not exist on type 'Console'.", "code": 2339, "category": "error" } ] } ```

Notably, the event for Property 'd' does not exist on type 'Console'. appears after the one for Property 'di' does not exist on type 'Console'.. This is unexpected because console.di happens after console.d. It suggests that either

resolritter commented 1 year ago

Please bear in mind that I do not have a precise procedure for reproducing this. As mentioned, the problem happens sometimes when I'm doing edits in quick succession.

resolritter commented 1 year ago

Closing this since I did not find a way of reliably reproducing the problem. I'll reopen in case I come up with a reproduction scenario.