serve-d (latest stable) causes Zeus to hang

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
sturt
Posts: 31
Joined: Wed Mar 13, 2024 12:57 am

serve-d (latest stable) causes Zeus to hang

Post by sturt »

New to Zeus, experienced with D language, moving to use it in Windows (10, 64-bit latest).
Just trying Zeus out for first time. Step one, get serve-d cooperating --- failed badly.

Followed this exactly.
https://www.zeusedit.com/lsp/d-serve-d.html
At the bottom of that page, followed your autocomplete test exactly. Ensured serve-d would run from the command line despite MS "smartscreen" blocking it at first before trying to configure it with the D document type in Zeus.

1.
Nothing happens.

2.
Language Server > Language Server > Display Server Output
Opens new tab with only this text. (Even with the trace argument for serve-d in in the D document settings Language Server tab.)
---------------------------------------------------------------------------
Zeus IDE - Version 3.99bh
Copyright (c) Xidicone P/L 2024 All rights reserved.
---------------------------------------------------------------------------
**** Unregistered Software. To be used for evaluation purposes only. ****
---------------------------------------------------------------------------

3.
All of the following cause Zeus to lock up (freeze) until killed. This happens only after an attempt to autocomplete is made.

A) Using the Language Server > Language Server > Options... (doesn't open, freezes Zeus)
B) Using the D document type properties Language Server tab (same behavior)

4.
If I kill the serve-d process associated with the Zeus process in the windows task manager, Zeus unfreezes.

I do not believe there is anything wrong with the latest stable serve-d from Github, serve-d_0.7.6-windows-x86_64.zip so please advise.
jussij
Site Admin
Posts: 2652
Joined: Fri Aug 13, 2004 5:10 pm

Re: serve-d (latest stable) causes Zeus to hang

Post by jussij »

Thanks for the bug report.

I will follow those same Zeus D language server instructions at this end, using that serve-d_0.7.6-windows-x86_64.zip release, and see if that can replicate the issue at end.

Cheers Jussi
jussij
Site Admin
Posts: 2652
Joined: Fri Aug 13, 2004 5:10 pm

Re: serve-d (latest stable) causes Zeus to hang

Post by jussij »

To keep my posts manageable, I'll reply to this issue with two posts.

This first post covers how Zeus was setup to test this issue, and how that setup was checked to make sure it was working.

The steps of this setup are shown below:

1. Downloaded this version of Serve-D:

Code: Select all

serve-d_0.7.6-windows-x86_64.zip
I extracted that contents of that zip file into this location:

Code: Select all

D:\Utilities\LSP\D\serve-d
as shown below:

Code: Select all

 Directory of D:\Utilities\LSP\D

13/03/2024  01:03 PM    <DIR>          .
13/03/2024  01:03 PM    <DIR>          ..
13/03/2024  01:03 PM    <DIR>          serve-d
13/03/2024  01:01 PM         3,450,408 serve-d_0.7.6-windows-x86_64.zip
               1 File(s)      3,450,408 bytes
               3 Dir(s)  267,375,611,904 bytes free
This is the contents of the serve-d folder:

Code: Select all

 Directory of D:\Utilities\LSP\D\serve-d

13/03/2024  01:03 PM    <DIR>          .
13/03/2024  01:03 PM    <DIR>          ..
20/07/2021  09:52 AM           349,696 libcurl.dll
20/07/2021  09:52 AM         1,178,112 libeay32.dll
08/01/2024  03:14 AM         7,915,008 serve-d.exe
20/07/2021  09:52 AM           265,216 ssleay32.dll
               4 File(s)      9,708,032 bytes
               2 Dir(s)  267,375,611,904 bytes free[.code]

[b]2.[/b]  I created a simple Zeus D Test project:

[code] Directory of c:\Projects\d\TestProject

11/09/2023  06:46 PM    <DIR>          .
11/09/2023  06:46 PM    <DIR>          ..
11/09/2023  06:46 PM               173 .gitignore
11/09/2023  06:46 PM               187 dub.json
11/09/2023  06:46 PM    <DIR>          source
11/09/2023  06:46 PM         1,521,664 testproject.exe
11/09/2023  06:46 PM         9,515,008 testproject.pdb
               4 File(s)     11,037,032 bytes
               3 Dir(s)  267,375,611,904 bytes free
The contents of the source\app.d file making up this project is nothing more than the following code:

Code: Select all

import std.stdio;
import std.typecons : No;

void main()
{
	string s = "Hello World";
	writeln(indexOf(s, 'W')); // 6
	writeln(indexOf(s, 'Z')); // -1
	writeln(indexOf(s, 'w', No.caseSensitive)); // 6

	writeln("Edit source/app.d to start your project.");
}
3. Opening the Zeus D Document Type the D Language Server details where set as shown below:
ls.png
ls.png (117.8 KiB) Viewed 7816 times
4. I create a Zeus workspace in that folder using the Workspace, Open Folder menu:

Code: Select all

c:\Projects\d\TestProject
That workspace is shown below:
ws.png
ws.png (47.87 KiB) Viewed 7816 times
5. Opening that app.d file starts the language server as is expected:
lsr.png
lsr.png (80.06 KiB) Viewed 7816 times
And the Zeus Language Server debug output shows the initialization worked and the didOpen notification was sent as shown below:
zi.png
zi.png (263.33 KiB) Viewed 7816 times
So the initial setup worked as expected, and the issues raised will covered in the next post.

Cheers Jussi
jussij
Site Admin
Posts: 2652
Joined: Fri Aug 13, 2004 5:10 pm

Re: serve-d (latest stable) causes Zeus to hang

Post by jussij »

Auto Complete and Goto Definition Issues

When an autocomplete request was initiated using this code:

Code: Select all

s.
The debug output shows this request being sent to the server as shown below:
ac.png
ac.png (241.94 KiB) Viewed 7811 times
That output shows Zeus sending the change notification in response to file changes (green rectangle), the auto complete request (blue rectangle) and the reply from the server (red rectangle).

That server responded with an empty array of results :?

The same thing happens if a goto definition request is sent to the server, with the server again replying with an empty result:

Code: Select all

{"jsonrpc":"2.0","id":16,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///C:/Projects/d/TestProject/source/app.d"},"position":{"line":8,"character":17}}}
Reply: {"id":16,"jsonrpc":"2.0","result":[]}
So I'm not sure why the server is not reply with any information :?:

Zeus Hanging Issue
I was able to replicate Zeus hanging issue and I think it relates to a disconnect between Zeus and server-d with regard to the shutdown request message.

As shown below, Zeus sends a shutdown request to the serve-d:

Code: Select all

{"jsonrpc":"2.0","id":9,"method":"shutdown"}
Ignoring Reply: {"id":9,"jsonrpc":"2.0","result":null}
Looking at the specification: https://microsoft.github.io/language-se ... /#shutdown

That response looks perfect and matches the specification.

Now I'll need to do some additional research, but I'm fairly certain after sending that shutdown request, Zeus sends and exit request: https://microsoft.github.io/language-se ... tion/#exit

As the specification says, the server is meant to exit and respond to that message:
The server should exit with success code 0 if the shutdown request has been received before; otherwise with error code 1.
and I'm fairly confident Zeus is hanging as it waits for a reply from the server for that exit request.

As you've found using Task manager to kill server-d.exe means Zeus comes out of that frozen state.
A) Using the Language Server > Language Server > Options... (doesn't open, freezes Zeus)
B) Using the D document type properties Language Server tab (same behavior)
Why these two actions are causing Zeus to hang, is both of these actions try to stop server-d server.

This issue can also be replicated using the Zeus Language Server, Language Server, Stop Language Server menu which also tries to stop the server. That menu will also cause a Zeus hang until the server-d.exe is killed using Task Manager.

Now obviously, something is not working correctly here, and I'll need to consult with the Language Server specification and the Zeus implementation of that specification to see which party is actually at fault.

Cheers Jussi
jussij
Site Admin
Posts: 2652
Joined: Fri Aug 13, 2004 5:10 pm

Re: serve-d (latest stable) causes Zeus to hang

Post by jussij »

Firstly, I can confirm Zeus does send a shutdown message, followed by an exit message.

Now the specification for the server exit request is as follows:
A notification to ask the server to exit its process. The server should exit with success code 0 if the shutdown request has been received before; otherwise with error code 1.
Notification:
method: 'exit'
params: none
The message Zeus sends to the server for this request is as follows:

Code: Select all

Content-Length: 40

{"jsonrpc":"2.0","id":6,"method":"exit"}
So, the exit notification message sent by Zeus does match the specification.

The server-d responded to that notification message with this reply:

Code: Select all

{"error":{"code":-32601,"data":null,"message":"Request method exit not found"},"id":6,"jsonrpc":"2.0"}
Hence the reason the server does not exit and the process continues to run.

Now, this looks like an issue for the server-d server, as it is not handling that exit request and it continues to run.

I also think there is a bug in Zeus, as it has not correctly handled this error condition for the exit request, instead assuming the server has exiting when it has not, and that then causes Zeus to hang as it waits for a redirected pipe to close.

So, Zeus will be changed to check for this error condition and respond accordingly.

However, that will still mean Zeus will not work well with serve-d as the server is not responding to these exit requests :!:

Cheers Jussi
jussij
Site Admin
Posts: 2652
Joined: Fri Aug 13, 2004 5:10 pm

Re: serve-d (latest stable) causes Zeus to hang

Post by jussij »

1. A new Zeus 3.99bi version can be download and it fixes the hang issue reported. This new version now reports the error indicating the server failed to respond to the exit request.

2. After turning on Verbose message handling I managed to generate this server-d completion error:

Code: Select all

Sent: Content-Length: 231

{"jsonrpc":"2.0","id":13,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///C:/Projects/d/TestProject/source/app.d"},"position":{"line":10,"character":3},"context":{"triggerKind":2,"triggerCharacter":"."}}}
Reply: 2024-03-13T19:20:10.032 [trace] serverbase\source\served\serverbase.d:410:collectGC GC run in 1 ms, 752 μs, and 9 hnsecs. Freed 183280 bytes (433072 bytes allocated, 4809808 bytes available)
Reply: 2024-03-13T19:20:15.122 [error] serverbase\source\served\serverbase.d:338:__lambda2 Failed processing notification: object.Exception@lsp\source\served\lsp\textdocumentmanager.d(466): Document 'file:///C:/Projects/d/TestProject/source/app.d' not found
Reply: ----------------
Reply: 0x00007FF6CAD91103
Reply: 0x00007FF6CAD90E34
Reply: 0x00007FF6CAD8F60D
Reply: 0x00007FF6CAD84CB1
Reply: 0x00007FF6CAD6BBA5
Reply: 0x00007FF6CAA1CB2D
Reply: 0x00007FF6CA8D437D
Reply: 0x00007FF6CA8D4330
Reply: 0x00007FF6CA8D3A71
Reply: 0x00007FF6CA8D344D
Reply: 0x00007FF6CA8AA9DD
Reply: 0x00007FF6CAD769F8
Reply: 0x00007FF6CAD76FA9
Reply: 2024-03-13T19:20:15.231 [trace] serverbase\source\served\serverbase.d:175:__lambda17 Calling provideComplete
Reply: {"code":-32603,"data":"object.Exception@lsp\\source\\served\\lsp\\textdocumentmanager.d(466): Document 'file:\/\/\/C:\/Projects\/d\/TestProject\/source\/app.d' not found\n----------------\n0x00007FF6CAD91103\n0x00007FF6CAD90E34\n0x00007FF6CAD8F60D\n0x00007FF6CAD84CB1\n0x00007FF6CAD6BBA5\n0x00007FF6CAA1CB2D\n0x00007FF6CA8B71E3\n0x00007FF6CA8C217D\n0x00007FF6CA8A9104\n0x00007FF6CA8AA652\n0x00007FF6CAD769F8\n0x00007FF6CAD76FA9","message":"Document 'file:\/\/\/C:\/Projects\/d\/TestProject\/source\/app.d' not found"}
Ignoring Reply: {"id":"0d45b395-4a7b-4515-ad40-fa098d09c673","jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{"section":"d"},{"section":"dfmt"},{"section":"dscanner"},{"section":"editor"},{"section":"git"}]}}
Reply: {"error":{"code":-32603,"data":"object.Exception@lsp\\source\\served\\lsp\\textdocumentmanager.d(466): Document 'file:///C:/Projects/d/TestProject/source/app.d' not found\n----------------\n0x00007FF6CAD91103\n0x00007FF6CAD90E34\n0x00007FF6CAD8F60D\n0x00007FF6CAD84CB1\n0x00007FF6CAD6BBA5\n0x00007FF6CAA1CB2D\n0x00007FF6CA8B71E3\n0x00007FF6CA8C217D\n0x00007FF6CA8A9104\n0x00007FF6CA8AA652\n0x00007FF6CAD769F8\n0x00007FF6CAD76FA9","message":"Document 'file:///C:/Projects/d/TestProject/source/app.d' not found"},"id":13,"jsonrpc":"2.0"}
Read Error: Document 'file:///C:/Projects/d/TestProject/source/app.d' not found
I suspect that message is the reason the completion is not returning any information.

However, I'm not sure why server-d is not liking that file URI sent as part of that request:

Code: Select all

"textDocument":{"uri":"file:///C:/Projects/d/TestProject/source/app.d"
If I put that file URI directly into Edge it displays the file just fine:
uri.png
uri.png (56 KiB) Viewed 7787 times
Cheers Jussi
sturt
Posts: 31
Joined: Wed Mar 13, 2024 12:57 am

Re: serve-d (latest stable) causes Zeus to hang

Post by sturt »

I got the new version, and I was unable to reproduce your thrown exception in serve-d when using the example from your D language server setup page.

However, I copied the JSON requests sent to serve-d from the Zeus debug window, and ran serve-d in a terminal, and tested them there using a script to supply a content length header line and blank line before the JSON text in each case, with suitable delays between requests. The responses were identical to those in the debug window.

No exception was thrown in the command line test.
sturt
Posts: 31
Joined: Wed Mar 13, 2024 12:57 am

Re: serve-d (latest stable) causes Zeus to hang

Post by sturt »

However, after the autocomplete request and before the response empty of possible completions, this went to stderr in the test in the terminal.

2024-03-13T15:58:14.343 [trace] serverbase\source\served\serverbase.d:175:__lambda17 Calling provideComplete
2024-03-13T15:58:14.344 [trace] source\served\types.d:503:activeInstance Setting active instance to <null>.
2024-03-13T15:58:14.345 [trace] source\served\commands\complete.d:379:provideComplete Completing from instance null
2024-03-13T15:58:14.346 [trace] source\served\commands\complete.d:426:provideComplete Providing no completion because no instance
sturt
Posts: 31
Joined: Wed Mar 13, 2024 12:57 am

Re: serve-d (latest stable) causes Zeus to hang

Post by sturt »

This would appear to be the difficulty. Strange because I know this works fine in conjunction with code-d in VS-code which is in use now.

Earlier the response to the textDocument/didOpen request in the terminal was

{"jsonrpc":"2.0","method":"coded/changedSelectedWorkspace","params":{"initialized":false,"name":"SDtest","selected":true,"uri":"file:///C:/Users/sturt/Documents/dprogs/"}}

which suggests that the workspace is not initialized at this juncture. (I don't know LSP so speculation.)
sturt
Posts: 31
Joined: Wed Mar 13, 2024 12:57 am

Re: serve-d (latest stable) causes Zeus to hang

Post by sturt »

So I am wondering if serve-d has been initialized correctly in that first request.
sturt
Posts: 31
Joined: Wed Mar 13, 2024 12:57 am

Re: serve-d (latest stable) causes Zeus to hang

Post by sturt »

I tried various beta versions of serve-d, but they all failed badly, including the one here
https://www.zeusedit.com/lsp/d-serve-d.html
which is serve-d_0.8.0-beta.14-windows-x86_64.zip
I don't understand how it is that those instructions show serve-d working.
It doesn't even produce an empty result on autocomplete when I do exactly what is stated there.
sturt
Posts: 31
Joined: Wed Mar 13, 2024 12:57 am

Re: serve-d (latest stable) causes Zeus to hang

Post by sturt »

Any suggestions?
jussij
Site Admin
Posts: 2652
Joined: Fri Aug 13, 2004 5:10 pm

Re: serve-d (latest stable) causes Zeus to hang

Post by jussij »

I don't understand how it is that those instructions show serve-d working.
I can actually understand why this would be the case; those instructions were created using the beta release of serve-d not the latest stable release.

As a test, I tried using the beta version of serve-d and the first thing I noticed was the exit request now worked as expected, and that beta server does now respond to requests for an exit.

I also found that beta version returns auto-complete information.

Code: Select all

{"jsonrpc":"2.0","id":3,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///C:/Projects/d/TestProject/source/app.d"},"position":{"line":10,"character":3},"context":{"triggerKind":2,"triggerCharacter":"."}}}
Reply: {"jsonrpc":"2.0","id":3,"result":{"isIncomplete":false,"items":[{"label":"alignof","kind":14,"sortText":"2_5_alignof"},{"label":"dup","kind":14,"sortText":"2_5_dup"},{"label":"idup","kind":14,"sortText":"2_5_idup"},{"label":"init","kind":14,"sortText":"2_5_init"},{"label":"length","kind":14,"sortText":"2_5_length"},{"label":"mangleof","kind":14,"sortText":"2_5_mangleof"},{"label":"ptr","kind":14,"sortText":"2_5_ptr"},{"label":"sizeof","kind":14,"sortText":"2_5_sizeof"},{"label":"stringof","kind":14,"sortText":"2_5_stringof"}]}}
However, due to a Language Server change made to Zeus in recent months, the latest Zeus failed to parse the JSON returned :(

Now, that JSON parsing error has been fixed in the latest Zeus 3.99bj release and that version can be downloaded from here: https://www.zeusedit.com/download.html

With the beta version of d-serve and the latest Zeus version I was now able get the auto complete to show as per the image shown on the instructions page:
ac.png
ac.png (137.4 KiB) Viewed 7729 times
Any suggestions?
While doing this testing, I noticed this message in the Language Server output:

Code: Select all

"message":" DCD is outdated. (target=0.15.2, installed=v0.13.6)"
What confused me, I could not identify which DCD was actually being using as there was no DCD executable in the path, so I really don't understand the meaning of that message :(

However, that did remind me Zeus can run DCD directly.

So, one suggestion would be, if you can't get serve-d to work, you could also try using the DCD as described here: viewtopic.php?t=7020

Jussi
sturt
Posts: 31
Joined: Wed Mar 13, 2024 12:57 am

Re: serve-d (latest stable) causes Zeus to hang

Post by sturt »

Thanks for the detailed reply, I'll try to replicate.
sturt
Posts: 31
Joined: Wed Mar 13, 2024 12:57 am

Re: serve-d (latest stable) causes Zeus to hang

Post by sturt »

I am mystified as to what the difference is between your and my Zeus installations that lead me to get no autocomplete at all --- not even an empty list of possibilities.

I didn't get Zeus to behave as you did with any of the 0.80 betas of serve-d. Just the same failure every time as soon as I try auto-complete. This included the following.

Code: Select all

2024-03-14T12:35:24.326 [warning] serverbase\source\served\utils\serverconfig.d:236:setupConfig_loadAfterTimeout This Language Client doesn't support configuration requests and also didn't send any configuration to serve-d. Initializing using default configuration
So somehow Zeus is not succeeding in configuring serve-d as I suspected earlier.
Post Reply