8000 Language server 3.3.0 crashes on a textDocument/codeAction request · Issue #694 · typescript-language-server/typescript-language-server · GitHub
[go: up one dir, main page]

Skip to content

Language server 3.3.0 crashes on a textDocument/codeAction request #694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spacebean opened this issue Feb 22, 2023 · 20 comments · Fixed by #709
Closed

Language server 3.3.0 crashes on a textDocument/codeAction request #694

spacebean opened this issue Feb 22, 2023 · 20 comments · Fixed by #709

Comments

@spacebean
Copy link

org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Request textDocument/codeAction failed with message: TypeScript Server Error (4.9.5)
Cannot read properties of undefined (reading 'heritageClauses')
TypeError: Cannot read properties of undefined (reading 'heritageClauses')
at getNodes (/usr/lib/node_modules/typescript/lib/tsserver.js:159276:63)
at Object.getCodeActions (/usr/lib/node_modules/typescript/lib/tsserver.js:159260:29)
at /usr/lib/node_modules/typescript/lib/tsserver.js:153574:77
at Object.flatMap (/usr/lib/node_modules/typescript/lib/tsserver.js:524:25)
at Object.getFixes (/usr/lib/node_modules/typescript/lib/tsserver.js:153574:23)
at /usr/lib/node_modules/typescript/lib/tsserver.js:169473:35
at Object.flatMap (/usr/lib/node_modules/typescript/lib/tsserver.js:524:25)
at Object.getCodeFixesAtPosition (/usr/lib/node_modules/typescript/lib/tsserver.js:169471:23)
at Session.getCodeFixes (/usr/lib/node_modules/typescript/lib/tsserver.js:181721:64)
at Session.handlers.ts.Map.ts.getEntries._a. (/usr/lib/node_modules/typescript/lib/tsserver.js:180100:61)
at /usr/lib/node_modules/typescript/lib/tsserver.js:182034:96
at Session.executeWithRequestId (/usr/lib/node_modules/typescript/lib/tsserver.js:182025:28)
at Session.executeCommand (/usr/lib/node_modules/typescript/lib/tsserver.js:182034:41)
at Session.onMessage (/usr/lib/node_modules/typescript/lib/tsserver.js:182062:35)
at process. (/usr/lib/node_modules/typescript/lib/tsserver.js:186218:31)
at process.emit (node:events:513:28)
at emit (node:internal/child_process:937:14)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

crashes

@rchl
Copy link
Member
rchl commented Feb 22, 2023

It doesn't reproduce here. Can you provide LSP logs from your editor since starting TLS?

@spacebean
Copy link
Author
spacebean commented Feb 22, 2023

It doesn't reproduce here. Can you provide LSP logs from your editor since starting TLS?

Full log of server communications?

typescript-language-server-log-20230222.log

@rchl
Copy link
Member
rchl commented Feb 22, 2023

Thanks. I can't immediately reproduce but maybe it needs more investigation...

But I can see that the log is very big with a lot of things going on before the crash. Are you able to reproduce consistently with just one file open and directly after server is started?

@spacebean
Copy link
Author

Thanks. I can't immediately reproduce but maybe it needs more investigation...

But I can see that the log is very big with a lot of things going on before the crash. Are you able to reproduce consistently with just one file open and directly after server is started?

typescript-language-server-log-20230222.log

@rchl
Copy link
Member
rchl commented Feb 22, 2023

That's the same log.

BTW. Why is it using global typescript instead of the one in the project? Do you have dependencies installed in that project?

Using Typescript version (bundled) 4.9.5 from path "/usr/lib/node_modules/typescript/lib/tsserver.js"

@spacebean
Copy link
Author

That's the same log.

That's not the same log.

@rchl
Copy link
Member
rchl commented Feb 22, 2023

Even if not the same, it's still not much different in terms of simplicity. There is still a to of hover and definition requests. Are those required to reproduce the issue?

@spacebean
Copy link
Author

Even if not the same, it's still not much different in terms of simplicity. There is still a to of hover and definition requests. Are those required to reproduce the issue?

No. Now I disable all features except inspection.

typescript-language-server-log-20230222_new.log

@rchl
Copy link
Member
rchl commented Feb 22, 2023

Right, I can reproduce now. One has to request code actions for that code that has error diagnostics due to unfinished import statement:

Screenshot 2023-02-22 at 10 18 06

That said, it's not a server crash but just an error response for the code action request. That typically doesn't have any noticeable implications for the user since such errors are typically not surfaced to the UI. Or at least I think they shouldn't be. Is that not the case in IntelliJ?

Previously the server was catching many requests so those were silent errors. I've assumed that it's fine to surface any such errors on the LSP level. That means that we can see issues in Typescript and can potentially report them in the Typescript repo. I'm open to changing it back if it causes problems though.

@chemicalderrick
Copy link

Hi there,
running into a very similar issue when using the language server in emacs via lsp-mode, as pictured below:
image
Whenever an error surfaces like this, the minibuffer will expand like this to accomodate the stack trace. The rest of the user experience is not affected, nor does it cause any other issues, but it's very irritating.
Checking the message and error buffers revealed no errors in emacs or elisp. See the full stack trace below. In the mean time, I think changing it back may be the better option.
https://gist.github.com/chemicalderrick/6f945e76803c0dd6a2a020315031071a

@rchl
Copy link
Member
rchl commented Mar 24, 2023

Maybe it's just a matter of returning better error code. I will look at it at some point.

@chemicalderrick
Copy link

I've isolated the request in question in case it helps:
https://gist.github.com/chemicalderrick/e42bb624067f051b15aa9dafa732c0c5

@rchl
Copy link
Member
rchl commented Mar 24, 2023

Regarding emacs' error message:

BADCLIENT: Bad error code, 7044 not found in range 37..37 (found: false, false); could have caused this error:

I'm not sure what that means exactly. Server is reporting a -32603 code in this case which is a valid error code (InternalError) in the LSP spec. Is it mis-parsing the error code? Would it not show the error pane if it would see this as a valid error code or would it still do it for valid error codes? I think you should report this to emacs' lsp-mode and we'll see what's the conclusion there.

@chemicalderrick
Copy link

I switched on logging the comms between lsp-mode and the language server again. For the request, see above. The exact response is: https://gist.github.com/chemicalderrick/5c3d274fe544f949e471bd0ce14e2c0b
Doesn't an InternalError point towards an error being encountered within the language server?

I just tested downgrading to typescript-language-server@3.2.0 and no error could be found. Neither in the language server's stderr, emacs' message buffer or in the communications protocol. Proper suggestions for fixing the issues presented by lsp-mode were provided:
https://gist.github.com/chemicalderrick/242186921127d0fa849740c3562bd727

@rchl
Copy link
Member
rchl commented Mar 24, 2023

Now I see that that specific error code is reserved for RPC communication. Server should use range between -32899 and -32800. Maybe lsp-mode won't open the panel on those but no guarantees from me.

@rchl
Copy link
Member
rchl commented Mar 27, 2023

I've released new version that doesn't report errors using internal error code. Not sure if that will help at all but feel free to let me know.

@chemicalderrick
Copy link

I'm afraid not. lsp-mode continues to report this as "Error from the Language Server: TypeScript Server Error (4.9.5)", not very useful. Stack trace is the same as before and I've logged the communication again 8000 if it helps.

https://gist.github.com/chemicalderrick/d2259ef25ffb98bf2c98289389113c4c

@rchl
Copy link
Member
rchl commented Nov 17, 2023

Do you still experience that with the latest version? I've recently fixed an issue that made the server crash on receiving an error from Typescript (#805).

@chemicalderrick
Copy link

The issue I had seems to have been resolved, thank you.

@rchl
Copy link
Member
rchl commented Nov 17, 2023

Thanks. Lets hope it's resolved then.

@rchl rchl closed this as completed Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants
0