Code Monkey home page Code Monkey logo

Comments (11)

joaotavora avatar joaotavora commented on June 25, 2024 2

Thanks @rchl for the investigation. I fixed it on my clients side, this was a combination of many factors like a missing complete error reproduction recipe (which I've now described back in the original issue). In certain combinations (invoking certain code actions with the cursor over whitespace, the Eglot client does send too many diagnostics). The server doesn't always error though, and when it does, it's impossible to make out what that long message and JS backtrace means. So, many thanks for having done that crucial part. I think this can be closed.

from typescript-language-server.

rchl avatar rchl commented on June 25, 2024

This looks like a typescript problem and ideally we'd have a reproduction and report it there. If you have vscode then you could try the same file there to verify that.

from typescript-language-server.

minikN avatar minikN commented on June 25, 2024

This looks like a typescript problem and ideally we'd have a reproduction and report it there. If you have vscode then you could try the same file there to verify that.

Hello,

I opened the same JSX file in vscode 1.85.1, and did S-C-p -> Source Action. It did not break. But my understanding is that VSCode doesn't use typescript-language-server, but rather taps into tsserver directly. Am I wrong? I searched through the tsserver log, but I couldn't find textDocument/codeAction there (it's over 60k lines long, can't even upload it).

VSCode seems to be using typescript 5.3.2 while emacs/eglot are using 5.3.3. Don't know if that makes any difference.

VSCode:

Version: 1.85.1
Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2
Date: 2023-12-13T09:47:11.635Z
Electron: 25.9.7
ElectronBuildId: 25551756
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Linux x64 6.6.8

from typescript-language-server.

rchl avatar rchl commented on June 25, 2024

VSCode doesn't use this server but the underlaying code is very similar since this server is based on vscode's code, with LSP layer added. So usually low-level issues like that reproduce the same.

You can make VSCode use different version of typescript by clicking on its status field. You would ideally install 5.3.3 in your project and then switch it to use project version.

from typescript-language-server.

rchl avatar rchl commented on June 25, 2024

And note that you've shared the source code of that file in the log since LSP logs include it when opening the file. So if you don't want to share it, you might want to remove that pastebin. I've downloaded it locally already so I can try to see if I can reproduce with just that file when I have some time.

from typescript-language-server.

rchl avatar rchl commented on June 25, 2024

I'm missing your dependencies and other project configuration but with that file the InlayHints request fails with:

{
    "code": 1,
    "message": "<semantic> TypeScript Server Error (5.3.3)\nDebug Failure. Unexpected node.\r\nNode ObjectBindingPattern was unexpected.\nError: Debug Failure. Unexpected node.\r\nNode ObjectBindingPattern was unexpected.\n    at visitForDisplayParts (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:165383:17)\n    at visitForDisplayParts (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:165188:11)\n    at /usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:165391:9\n    at Array.forEach (<anonymous>)\n    at visitDisplayPartList (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:165387:13)\n    at visitForDisplayParts (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:165340:11)\n    at typeToInlayHintParts (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:165113:5)\n    at visitVariableLikeDeclaration (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:164921:23)\n    at visitor (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:164843:7)\n    at visitNodes (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:30235:22)\n    at forEachChildInVariableDeclarationList (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:30454:12)\n    at forEachChild (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:30744:35)\n    at visitor (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:164858:12)\n    at visitNode2 (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:30227:18)\n    at forEachChildInVariableStatement (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:30451:59)\n    at forEachChild (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:30744:35)\n    at visitor (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:164858:12)\n    at visitNodes (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:30235:22)\n    at forEachChildInSourceFile (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:30448:12)\n    at forEachChild (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:30744:35)\n    at visitor (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:164858:12)\n    at Object.provideInlayHints (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:164819:3)\n    at Object.provideInlayHints2 [as provideInlayHints] (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:145844:34)\n    at IpcIOSession.provideInlayHints (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:184197:48)\n    at provideInlayHints (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:183356:43)\n    at /usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:185375:69\n    at IpcIOSession.executeWithRequestId (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:185367:14)\n    at IpcIOSession.executeCommand (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:185375:29)\n    at IpcIOSession.onMessage (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:185417:51)\n    at process.<anonymous> (/usr/local/workspace/github/typescript-language-server/node_modules/typescript/lib/tsserver.js:186999:14)\n    at process.emit (node:events:514:28)\n    at emit (node:internal/child_process:937:14)\n    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)"
}

Not sure how related it is but it's still something for typescript to handle.

from typescript-language-server.

minikN avatar minikN commented on June 25, 2024

And note that you've shared the source code of that file in the log since LSP logs include it when opening the file. So if you don't want to share it, you might want to remove that pastebin. I've downloaded it locally already so I can try to see if I can reproduce with just that file when I have some time.

Yeah, I noticed that too. Anyway it already happened 😝

from typescript-language-server.

minikN avatar minikN commented on June 25, 2024

And note that you've shared the source code of that file in the log since LSP logs include it when opening the file. So if you don't want to share it, you might want to remove that pastebin. I've downloaded it locally already so I can try to see if I can reproduce with just that file when I have some time.

I added typescript version 5.3.3 to VSCode, but that didn't change, it still works. But I don't know how reliable that is, because VSCode sends

    {
      "seq": 19,
      "type": "request",
      "command": "getApplicableRefactors",
      "arguments": {
        "file": "/home/db/.local/share/git/gaia/client/platform/web/src/ui/Component/File/Hotspot.jsx",
        "startLine": 14,
        "startOffset": 27,
        "endLine": 14,
        "endOffset": 27,
        "triggerReason": "implicit",
        "includeInteractiveActions": true
      }
    }

which is not the same request I send from eglot.

Any other ideas on how to reproduce this?

from typescript-language-server.

rchl avatar rchl commented on June 25, 2024

Note that the jsx files should use javascriptreact language ID in didOpen notification. Typescript has JSX (and TSX) specific logic in some cases so it needs to know the correct language ID for proper functioning.

from typescript-language-server.

rchl avatar rchl commented on June 25, 2024

I have reproduced your error by hardcoding the parameters in the textDocument/codeAction request to the same ones that your editor sends.

I believe the reason for that error might be that your editor doesn't quite follow the expected LSP behavior (which I'm not sure if is very precisely specified).

Your editor is sending all file diagnostics in the params.context.diagnostics property:

{
    "jsonrpc": "2.0",
    "id": 6,
    "method": "textDocument/codeAction",
    "params": {
        "textDocument": {
            "uri": "file:///home/db/.local/share/git/gaia/client/platform/web/src/ui/Component/File/Hotspot.jsx"
        },
        "range": {
            "start": {
                "line": 0,
                "character": 0
            },
            "end": {
                "line": 0,
                "character": 0
            }
        },
        "context": {
            "diagnostics": <INCLUDES ALL DIAGNOSTICS HERE>
        }
    }
}

while the expected behavior is that the editor only includes diagnostics that overlap the params.range range.

The typescript error Bad error code, 7044 not found in range 592..592 seems to imply that it didn't find the 7044 diagnostic (which is one of those provided in the request) in the current range.

So it looks like an LSP client bug.

from typescript-language-server.

rchl avatar rchl commented on June 25, 2024

That is actually precisely specified:

export interface [CodeActionContext](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionContext) {
	/**
	 * An array of diagnostics known on the client side overlapping the range
	 * provided to the `textDocument/codeAction` request. They are provided so
	 * that the server knows which errors are currently presented to the user
	 * for the given range. There is no guarantee that these accurately reflect
	 * the error state of the resource. The primary parameter
	 * to compute code actions is the provided range.
	 */
	diagnostics: [Diagnostic](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnostic)[];

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionContext

from typescript-language-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.