richterger / Perl-LanguageServer

Language Server for Perl
Other
224 stars 53 forks source link

Language Server stuck or frozen on a certain point #30

Closed carlosfrodriguez closed 3 years ago

carlosfrodriguez commented 4 years ago

Initially the file gets the correctly highlighted any syntax error, but after a while it starts to detect false positives or even stop checking the file on new lines.

This false positives refers to the file on a previous state. The only way to make it work again is restarting or reloading VS, I have to do this more than 30 or 40 times per day.

I see no error logs in the language server output.

richterger commented 4 years ago

What OS the LanguageServer runs on?

carlosfrodriguez commented 4 years ago

Hi @richterger, macOS Catalina

richterger commented 4 years ago

I do not work on Mac, so I have no chance to test it. I would expect that there is a minor difference e.g. in handling stdin/stdout or something similar. Major reason, that LanguageServer gets stuck, is when the communication between vscode and ls gets out of sync. So the best is to set log level to 2. Then you can watch the communication in the output pane. It's important to find out what's happinging when it get stuck. In case you have a clue, please try to narrow it down and if possible send me a small testcase.

carlosfrodriguez commented 4 years ago

Hi @richterger I'm not sure how to send you a test case this could happen in a file with thousand lines of code or even in a small file with 60 lines, and they both get fixed on 2 ways, either reload or sometimes I add 5 to 10 empty lines and save. I do not see anything special in the logs, but just an old state of the code. e.g.

LS: end aio read cnt=221
LS: line=<Content-Length: 1591>
LS: line=<>
LS: read data={"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///Users/carlos/Dev/XXX/Framework/XXX-X_X/Kernel/Test/Role/Selenium/Agent/HandlesWidgets.pm","version":189},"contentChanges":[{"text":"# --\n# Copyright (C) 2001-2020 XXXX XX, https://xxx.xx/\n# --\n# This software comes with ABSOLUTELY NO WARRANTY. For details, see\n# the enclosed file COPYING for license information (GPL). If you\n# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.\n# --\n\npackage Kernel::Test::Role::Selenium::Agent::HandlesWidgets;\n\nuse strict;\nuse warnings;\n\n=head1 NAME\n\nKernel::Test::Role::Selenium::Agent::HandlesWidgets - role to interact with widgets in Selenium tests.\n\n=cut\n\nuse Moose::Role;\n\n\n=head2 DisableWidgets()\n\nDisable all widgets but the ActiveWidgetName in the system configuration.\n\n    $Test->DisableWidgets(\n        WodgetSetting    => 'AgentFrotnend::SomeScreen::Widget',\n        ActiceWidgetName => 'somename',\n    );\n\n=cut\n\nsub DisableWidgets {\n    my ($Self, %Param) = @_;\n\n    for (qw(WidgetSetting ActiveWidgetName)) {\n        die \"Need $_!\" if !$Param{$_};\n    }\n\n    my $Widgets = $Kernel::OM->Get('Kernel::Config')->Get($Param{WidgetSetting});\n\n    WIDGET:\n    for my $Widget ( sort keys %{$Widgets} ) {\n        next WIDGET if $Widget eq $Param{ActiveWidgetName};\n\n        $Self->ConfigSettingChange(\n            Valid => 0,\n            Key   => \"$Param{WidgetSetting}###$Widget\",\n            Value => {},\n        );\n    }\n\n    ret\n};\n\n\nno Moose::Role;\n\n1;\n\n"}]}}
LS: read header={ "Content-Length" => 1591 }
LS: ---> Request: {
   "method" : "textDocument/didChange",
   "jsonrpc" : "2.0",
   "params" : {
      "textDocument" : {
         "uri" : "file:///Users/carlos/Dev/XXXX/Framework/XXX-X_X/Kernel/Test/Role/Selenium/Agent/HandlesWidgets.pm",
         "version" : 189
      },
      "contentChanges" : [
         {
            "text" : "# --\n# Copyright (C) 2001-2020 XXXX XX, https://xxxx.xx/\n# --\n# This software comes with ABSOLUTELY NO WARRANTY. For details, see\n# the enclosed file COPYING for license information (GPL). If you\n# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.\n# --\n\npackage Kernel::Test::Role::Selenium::Agent::HandlesWidgets;\n\nuse strict;\nuse warnings;\n\n=head1 NAME\n\nKernel::Test::Role::Selenium::Agent::HandlesWidgets - role to interact with widgets in Selenium tests.\n\n=cut\n\nuse Moose::Role;\n\n\n=head2 DisableWidgets()\n\nDisable all widgets but the ActiveWidgetName in the system configuration.\n\n    $Test->DisableWidgets(\n        WodgetSetting    => 'AgentFrotnend::SomeScreen::Widget',\n        ActiceWidgetName => 'somename',\n    );\n\n=cut\n\nsub DisableWidgets {\n    my ($Self, %Param) = @_;\n\n    for (qw(WidgetSetting ActiveWidgetName)) {\n        die \"Need $_!\" if !$Param{$_};\n    }\n\n    my $Widgets = $Kernel::OM->Get('Kernel::Config')->Get($Param{WidgetSetting});\n\n    WIDGET:\n    for my $Widget ( sort keys %{$Widgets} ) {\n        next WIDGET if $Widget eq $Param{ActiveWidgetName};\n\n        $Self->ConfigSettingChange(\n            Valid => 0,\n            Key   => \"$Param{WidgetSetting}###$Widget\",\n            Value => {},\n        );\n    }\n\n    ret\n};\n\n\nno Moose::Role;\n\n1;\n\n"
         }
      ]
   }
}

LS: handle_req id=
LS: method=_rpcnot_didChange
LS: start aio read
start perl -c
perl -c rc=255 out= errout=Bareword "ret" not allowed while "strict subs" in use at - line 55.
BEGIN not safe after errors--compilation aborted at - line 58.

LS: <--- Notification: {
   "method" : "textDocument/publishDiagnostics",
   "jsonrpc" : "2.0",
   "params" : {
      "uri" : "file:///Users/carlos/Dev/XXXX/Framework/XXXX-X_X/Kernel/Test/Role/Selenium/Agent/HandlesWidgets.pm",
      "diagnostics" : [
         {
            "range" : {
               "end" : {
                  "line" : 55,
                  "character" : 0
               },
               "start" : {
                  "character" : 0,
                  "line" : 54
               }
            },
            "message" : "Bareword \"ret\" not allowed while \"strict subs\" in use at - line 55."
         },
         {
            "range" : {
               "start" : {
                  "line" : 57,
                  "character" : 0
               },
               "end" : {
                  "character" : 0,
                  "line" : 58
               }
            },
            "message" : "BEGIN not safe after errors--compilation aborted at - line 58."
         }
      ]
   }
}

As you can see it is complaining about a line with 'ret', in fact that line was ' return 1;'

But for some reason Language Sever got an intermediate state and it does not realize that the line changes after the 't' character.

Please let me know if I can help with anything else. Some of my colleagues also suffer the same problem and is very disappointing.

BTW when the Server is stuck then it also fail to load the file outline (document symbols), also a reload this the problem.

richterger commented 4 years ago

As you can see in

"contentChanges" : [ { "text" : "# --\n# Copyright ..... ret\n};\n\n\nno Moose::Role;\n\n1;\n\n" }

vscode really only passes "ret" to the LanguageServer. If you are now correct the line, does you see new lines in the Log? Normaly you should see a "textDocument/didChange" message, when you make some changes to your document.

carlosfrodriguez commented 4 years ago

Yes, there are no new entries in the LenguageServer log.

richterger commented 3 years ago

Should be fixed in c3e8670c41a28027b27dbe5d9a8394c49ce640c7

carlosfrodriguez commented 3 years ago

Hi @richterger

Thank you, are you planning a new release soon?

richterger commented 3 years ago

Yes, the plan is to release it during the next 7 to 14 days