erlang-ls / erlang_ls

The Erlang Language Server
https://erlang-ls.github.io/
Apache License 2.0
624 stars 136 forks source link

typer process crash filling up my log file #1080

Open alanz opened 3 years ago

alanz commented 3 years ago

Describe the bug My emacs session slows down terribly when I open an OTP erlang source file.

The reported stack trace is


[2021-09-01T10:54:17.698741+01:00] [error] Generic server <0.6584.0> terminating. Reason:
{{case_clause,none},
[{els_typer,get_type_info,2,[{file,"..../erlang_ls/apps/els_lsp/src/els_typer.erl"},{line,247}]}
,{els_typer,get_type_spec,3,[{file,"..../erlang_ls/apps/els_lsp/src/els_typer.erl"},{line,233}]}
,{els_code_lens_suggest_spec,get_type_spec,2,[{file,"....../erlang_ls/apps/els_lsp/src/els_code_lens_suggest_spec.erl"},{line,76}]}
,{els_code_lens_suggest_spec,command,3,[{file,"..../erlang_ls/apps/els_lsp/src/els_code_lens_suggest_spec.erl"},{line,50}]}
,{els_code_lens,make_lens,4,[{file,"..../erlang_ls/apps/els_lsp/src/els_code_lens.erl"},{line,102}]}

The offending line is the case caluse below, where map__lookup/2 returns none if the lookup fails.

-spec get_type_info({any(), any()}, dict:dict()) -> {any(), any()}.
get_type_info(Func, Types) ->
  case map__lookup(Func, Types) of
    {contract, _Fun} = C -> C;
    {_RetType, _ArgType} = RA -> RA
  end.

To Reproduce Open an erlang file, go to definition to something in OTP

Expected behavior Responsive language server experience browsing the code

Actual behavior Very sluggish behaviour, as the emacs *lsp-log* buffer rapidly becomes very large.

Context

robertoaloi commented 3 years ago

Interesting. Looking at the upstream version of TypEr, I noticed two things:

  1. The version of Erlang LS differs from upstream. The upstream version didn't change for 5 years, so I wonder why
  2. The upstream version handles the none as a fatal error.

Will need to check this deeper, thanks for the report!

robertoaloi commented 3 years ago

Replying to myself. After importing it, I modified els_typer according to our needs. The handling of none was removed as part of that effort.

robertoaloi commented 3 years ago

@alanz I'm not able to reproduce this issue. Can I ask you which module in OTP you tried to access?