ferd / erl_subgraph_compile

A rebar plugin to only do partial re-builds of some files without any safety checks.
Apache License 2.0
9 stars 1 forks source link

Plugin crashes on non-existing files #3

Open robertoaloi opened 4 years ago

robertoaloi commented 4 years ago
$ rebar3 erl_subgraph_compile -f src/foo.erl
===> Expanded command sequence to be run: [{default,app_discovery},
                                                  {default,
                                                   erl_subgraph_compile}]
===> Provider: {default,app_discovery}
===> Provider: {default,erl_subgraph_compile}
===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump
===> Uncaught error: {case_clause,false}
===> Stack trace to the error location:
[{erl_subgraph_compile_prv,level_order,3,
                           [{file,"/Users/robert.aloi/git/github/erlang-ls/rebar3_bsp/priv/sample/_build/default/plugins/erl_subgraph_compile/src/erl_subgraph_compile_prv.erl"},
                            {line,196}]},
 {erl_subgraph_compile_prv,resolve_chain,3,
                           [{file,"/Users/robert.aloi/git/github/erlang-ls/rebar3_bsp/priv/sample/_build/default/plugins/erl_subgraph_compile/src/erl_subgraph_compile_prv.erl"},
                            {line,186}]},
 {erl_subgraph_compile_prv,do,1,
                           [{file,"/Users/robert.aloi/git/github/erlang-ls/rebar3_bsp/priv/sample/_build/default/plugins/erl_subgraph_compile/src/erl_subgraph_compile_prv.erl"},
                            {line,50}]},
 {rebar_core,do,2,
             [{file,"/Users/robert.aloi/git/github/erlang/rebar3/src/rebar_core.erl"},
              {line,154}]},
 {rebar3,run_aux,2,
         [{file,"/Users/robert.aloi/git/github/erlang/rebar3/src/rebar3.erl"},
          {line,181}]},
 {rebar3,main,1,
         [{file,"/Users/robert.aloi/git/github/erlang/rebar3/src/rebar3.erl"},
          {line,66}]},
 {escript,run,2,[{file,"escript.erl"},{line,758}]},
 {escript,start,1,[{file,"escript.erl"},{line,277}]}]
===> When submitting a bug report, please include the output of `rebar3 report "your command"`
ferd commented 4 years ago

Yep. Will crash on a file that isn't in the DAG, but also on a file that is in the DAG but not on disk (since usually the DAG analysis phase clears all of that stuff up).

Needs handling, unsure what proper error reporting should be like.

robertoaloi commented 4 years ago

From a BSP perspective, I would start by having the build server notifying the client (the language server) of the fact, so that a message can be shown to the user or a log message can be produced. Later on, we could probably check if we can recover from this situation by updating the DAG or similar (if this turns out to be a real issue).

https://build-server-protocol.github.io/docs/specification#log-message

ferd commented 4 years ago

yeah I guess we should differentiate between two types of errors:

  1. the compilation step failed because of an issue with a file that is present and working
  2. there was a problem with the DAG which would likely be solved by running the full analysis

I don't think this plugin should be able to fix 2, merely detect the bad conditions. The full range of operations required to fix the DAG are those that lead to a full run, which is considered as too slow to be done inline. But there isn't at this time a good way to figure out "how to do a partial re-analysis that may or may not fix things"; at this point it's all or nothing. Rebar3 compile does the all, this plugin does the nothing.