Skip to content
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

Update Typescript Language Server to 4.4.3 #7732

Merged

Conversation

matthiasblaesing
Copy link
Contributor

  • Update typescript to 5.5.4 (implies minimal node version 10)
  • Update typescript-language-server to 5.5.4
  • Add PublishDiagnosticsCapabilities to declared capabilities
  • Added handling of SematicHighlighting for tokenTypeId -1: Assume this means "only consider modifier"
  • Document update procedure
  • Add @todo for handling mapping mimetype -> languageId

@matthiasblaesing matthiasblaesing added LSP [ci] enable Language Server Protocol tests TypeScript [ci] enable web job ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Sep 4, 2024
@matthiasblaesing matthiasblaesing added this to the NB24 milestone Sep 4, 2024
@matthiasblaesing
Copy link
Contributor Author

@Chris2011 if I remember correctly, you are a user of the typescript support. Could you give the testbuild from this a spin?

@Chris2011
Copy link
Contributor

Sure, will do today and will let you know. Thx :)

@Chris2011
Copy link
Contributor

I created a new ts file and when I have this piece of code:

const t: Record

when call code completion after the end of the Record token and when I remove charaacter by character from the end of the Record token, I got this exception:

org.eclipse.lsp4j.jsonrpc.ResponseErrorException: Request completionItem/resolve failed with message: Cannot read properties of undefined (reading 'file')
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:842)
Caused: java.util.concurrent.ExecutionException
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
[catch] at org.netbeans.modules.lsp.client.bindings.LspCompletionItem.resolveDocumentation(LspCompletionItem.java:104)
	at org.netbeans.modules.lsp.client.bindings.AbstractCompletionItem$1.query(AbstractCompletionItem.java:154)
	at org.netbeans.spi.editor.completion.support.AsyncCompletionTask.run(AsyncCompletionTask.java:198)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1403)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2018)

@Chris2011
Copy link
Contributor

Another one for this piece of code

const t = (obj) => {
    
}

t({
    name: 2
})

When I remove character by character from the end of the file until beginning of name, I got this exception:

org.eclipse.lsp4j.jsonrpc.ResponseErrorException: <semantic> TypeScript Server Error (5.2.2)
Debug Failure. Expected 38 <= 37
Error: Debug Failure. Expected 38 <= 37
    at assertDiagnosticLocation (c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:16251:11)
    at createFileDiagnostic (c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:20244:3)
    at getRangeToExtract2 (c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:141104:23)
    at Object.getRefactorActionsToExtractSymbol [as getAvailableActions] (c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:140915:26)
    at c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:137351:222
    at flatMapIterator (c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:2630:19)
    at flatMapIterator.next (<anonymous>)
    at arrayFrom (c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:3184:14)
    at Object.getApplicableRefactors (c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:137349:10)
    at Object.getApplicableRefactors2 [as getApplicableRefactors] (c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:144816:32)
    at IpcIOSession.getApplicableRefactors (c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:184449:41)
    at getApplicableRefactors (c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:182686:43)
    at c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:184838:69
    at IpcIOSession.executeWithRequestId (c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:184830:14)
    at IpcIOSession.executeCommand (c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:184838:29)
    at IpcIOSession.onMessage (c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:184880:51)
    at process.<anonymous> (c:\Projekte\Others\nuxt-asciidoc\node_modules\typescript\lib\tsserver.js:186461:14)
    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)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:842)
Caused: java.util.concurrent.ExecutionException
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
[catch] at org.netbeans.modules.lsp.client.bindings.LanguageClientImpl$DiagnosticFixList.lambda$getFixes$1(LanguageClientImpl.java:340)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1403)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2018)

@matthiasblaesing
Copy link
Contributor Author

@Chris2011 thanks for the test. Could reproduce the second problem, but failed for the first one. I asked google for similar problems and it seems the typescript-language-server is regressing. Similar reports can be found for Webstorm/IntelliJ.

There were indications, that typescript 5.5.X might be the problem, but downgrading to 5.4.X did not help.

I have to see whether manually patching the current lsp integration to be runnable with up-to-date node versions or whether there is a "known-good" set of typescript and node.

Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the inline comment on a license text.

@@ -1,6 +1,6 @@
Name: typescript
Description: TypeScript is a language for application scale JavaScript development
Version: 4.1.4
Version: 5.5.4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but this seems highly suspicious to me. The typescript-5.5.4.zip file contains typescript/ThirdPartyNoticeText.txt, and I don't see the content of the file here. Is there a reason to believe the typescript/ThirdPartyNoticeText.txt does not apply here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid point. I admit, I did not check, on the other hand, the relevant file would be NOTICE, but so be it.

@Chris2011
Copy link
Contributor

Chris2011 commented Sep 7, 2024

@matthiasblaesing for the first problem, you need to open the code completion first and delete char by char.

For the second error, in the first line you can see this: TypeScript Server Error (5.2.2) dunno whether this is the TS version or not. But I guess so.

Lemme know what I can check more

@Chris2011
Copy link
Contributor

I read the news, that TypeScript 5.6 was released. I dunno whether this will fix the bug or not, but is it maybe possible to handle TS as maven too? So we bundle typescript hard to NetBeans and everytime an update was released we need to update it. Afaik maven is bundled with NetBeans, but you can choose your own version of it. Similar to bower, grunt, gulp, node, karma etc. It is just an idea but could be part of a different PR.

@matthiasblaesing
Copy link
Contributor Author

@lahodaj I updated the prepare project to also cover the renamed ThirdPartyNoticeText.txt file. Both variants are now covered.
@Chris2011 I updated typescript to 5.6.2 and I did not see a change. However, I think the problem was, that DiagnosticFixList called into the typescript lsp with an out of bounds index. This is now guarded and it seems to fix the problem. Even if the problem resurfaces, the problem is logged with a lower level, only being reported in the messages.log, but not on the GUI.

Could you please both have another look?

@Chris2011
Copy link
Contributor

@matthiasblaesing FYI will do it today.

@Chris2011
Copy link
Contributor

Chris2011 commented Sep 18, 2024

@matthiasblaesing So it seems, that the second issue is gone, the first still exists. I created a screen capture, hope it helps. It happens, when you first open the code completion, than delete a character or sometimes a whole word.

Aufzeichnung.2024-09-18.211905.mp4

But it also seems, for the first view, that it is not affecting the editor as far as I can see.

@matthiasblaesing
Copy link
Contributor Author

@Chris2011 thank you. Indeed I was able to reproduce. The issue is not as easily fixable as 110c7db and I also think the server should be able to handle delayed resolve of completion and not raise an exception. As I can't prevent it, I only reduced log level to INFO, so problem is logged, but user can continue working.

For me this fixes the problem. Can you confirm?

@Chris2011
Copy link
Contributor

@matthiasblaesing I can confirm that I can't see any exception anymore. Thx :)

@matthiasblaesing
Copy link
Contributor Author

@Chris2011 thanks for taking the time to test, reproduce and recheck!

- Update typescript to 5.6.2 (implies minimal node version 10)
- Update typescript-language-server to 4.4.3
- Add PublishDiagnosticsCapabilities to declared capabilities
- Added handling of SematicHighlighting for tokenTypeId -1: Assume this means "only consider modifier"
- Document update procedure
- Add @todo for handling mapping mimetype -> languageId
…tic beyond document, reduce log level)

 - Log errors in DiagnosticFixList#getFixes by using LOG#log with level
   INFO, instead of Exceptions#printStackTrace which logs on level
   SEVERE. This reduces the level so much, that is not raised as a user
   visible (exception error marker in status line) message anymore.

 - it could happen, that the fixlist for a position outside the
   document range is queried, when characters at the end of a document
   were deleted. This is no prevented.
@matthiasblaesing
Copy link
Contributor Author

I cleaned up the history. @jlahoda you requested changes. Could you please check if they were addressed? I'd like to get this in.

@matthiasblaesing
Copy link
Contributor Author

I intent to merge this next saturday. Typescript LSP fails to run on windows with node LTS and that is fixed by this. The change request was addressed, I ran with this the last weeks, so I think this is good to be merged.

If anyone wants to object, please do so now.

@matthiasblaesing matthiasblaesing merged commit 2b07788 into apache:master Oct 19, 2024
31 checks passed
@matthiasblaesing matthiasblaesing deleted the update-typescript-lsp branch November 4, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) LSP [ci] enable Language Server Protocol tests TypeScript [ci] enable web job
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants