Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live reload breaks debugging session in elixirLS debugger #133

Open
lukaszsamson opened this issue Jan 9, 2023 · 4 comments
Open

Live reload breaks debugging session in elixirLS debugger #133

lukaszsamson opened this issue Jan 9, 2023 · 4 comments

Comments

@lukaszsamson
Copy link

I know that this most likely not be planned but there are repeated bugs and support requests related to that issue.

elixir-lsp/elixir-ls#797
elixir-lsp/elixir-ls#798

There are 2 problems when phoenix is run under elixirLS debugger

  1. The code reloader (https://github.com/phoenixframework/phoenix/blob/master/lib/phoenix/code_reloader/server.ex) is purging and reloading modules on the fly with no regard for the ongoing debug session. The reloaded modules are not properly interpreted via erlang debugger.
  2. It is messing with IO interception. Debug Adapter Protocol has strict requirements on stdout IO. All standard IO needs to be sent as JSONRPC protocol messages.
@josevalim
Copy link
Member

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.

@CharlesIrvineKC
Copy link

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.

@josevalim
Copy link
Member

@lukaszsamson if you can reproduce it we should do a pairing session :)

@CharlesIrvineKC
Copy link

CharlesIrvineKC commented Jan 10, 2023

There may be multiple error paths, but here is one that comes up often. To reproduce in vscode:

  1. Create a new Phoenix 1.6 app: "mix phx.new hello".
  2. Create a launch config. Add: "task": "phx.server".
  3. In "page_controller.ex" add a break point to line 5.
  4. Execute: Run/Start Debugging.
  5. Go to "localhost:4000" to trigger the breakpoint. Continue past the breakpoint.
  6. Insert "IO.inspect(conn)" above line 5.
  7. Reset breakpoint to new line 5 and refresh "localhost:4000".
  8. The following error occurs:
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants