Open lukaszsamson opened 1 year ago
This is tricky because I can’t come with good suggestions to address this. At best we could block the code reloader but I am not sure that would help either.
Thought I would add a note specifying the impact of and work around for the problem. Basically, any time code is changed while in a debugging session, the Elixir compiler will likely throw spurious (false positive) errors. The work around is to bounce the debugger. This clears the problem and allows debugging to continue.
@lukaszsamson if you can reproduce it we should do a pairing session :)
There may be multiple error paths, but here is one that comes up often. To reproduce in vscode:
Compiling 1 file (.ex)
== Compilation error in file lib/hello_web/controllers/page_controller.ex ==
** (UndefinedFunctionError) function HelloWeb.__using__/1 is undefined or private. However there is a macro with the same name and arity. Be sure to require HelloWeb if you intend to invoke this macro
(hello 0.1.0) HelloWeb.__using__(:controller)
lib/hello_web/controllers/page_controller.ex:2: (module)
(elixir 1.14.2) lib/kernel/parallel_compiler.ex:346: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/7
Is there any update to this issue or other workarounds? This makes the dev experience while debugging (I'm basically always debugging) pretty painful.
No. To address it either phoenix should check if modules are interpreted and call :int.ni
after it recompiles or emit some event that the debug adapter can listen for and reinterpret. Probably breakpoints also need to be reset after that. A workaround could be to periodically reinterpret all modules in the VM that match launch config settings.
My impression is that everyone in the Phoenix development community has given up on using a debugger and just use IO.inspect. Coming from a Java background where everyone used a debugger, I struggled for quite a while trying to get debugging working with Phoenix and ElixirLS and finally gave up and gave in to using IO.inspect. It's a shame I think. A lot of people would be very happy to be able to use the ElixirLS debugger with Phoenix.
Ya this is a shame. I have been trying to audit phoenix and see if I should propose we switch to it for some things at the company I work for, but this is a hard blocker. I really love this ecosystem but being unable to use the tools like we're accustomed and requiring console logging is a non-starter.
That being said, thank you all that have worked on these projects and gotten things this far. Hopefully this gets fixed in the future, and then I'll revisit.
I did a post for this on the forum. Let's see if anyone responds.
https://elixirforum.com/t/source-level-debugging-for-phoenix-and-phoenix-liveview-apps/65400
I know that this most likely not be planned but there are repeated bugs and support requests related to that issue.
https://github.com/elixir-lsp/elixir-ls/issues/797 https://github.com/elixir-lsp/elixir-ls/issues/798
There are 2 problems when phoenix is run under elixirLS debugger