Closed hexpunk closed 4 years ago
The debugger does not work on Elixir 1.10.0-1.10.2 (the fix has been merged upstream but we need to wait for https://github.com/elixir-lang/elixir/pull/9864 to be released in 1.10.3). Will close this if a workaround can be found or Elixir 1.10.3 is released.
Thank you so much for the information. (I thought I was losing my mind.)
Does that mean the debugger works on the 1.9.x releases of Elixir? I might try downgrading if it means I can use the debugger.
Yes it should. I also might be able to prep a PR that will improve 1.10 support.
Why does the boilerplate project created with phx_new
seemingly work with the debugger okay?
FWIW, I just tried running my app with Elixir 1.9.4, but there's code in my app that's using functions like compile_env!
that were introduced in the Elixir 1.10.x branch, so I guess I'll just have to wait for the 1.10.3 release before I can use the debugger. 😢
Why does the boilerplate project created with phx_new seemingly work with the debugger okay?
I'm not sure quite what you're saying. I don't expect this to work on Elixir 1.10
I was able to spin up a basic "hello" project using phx_new
running on Elixir 1.10.2 and I was able to get the debugger to attach to it and break at breakpoints.
Is there a more complicated project that reproduces the error that you could share?
Unfortunately, no. The one I'm having trouble with is my employer's code. I'll wait until the fixed version of Elixir comes out and if it still doesn't work, I'll dig deeper then.
FYI, changed the title and pinned this for better visibility until the next release of elixir.
@JayAndCatchFire et. al. Elixir 1.10.3 is now released :tada:! So I've added a warning in #221 (which will be included in 0.3.4 eventually) that warns you when debugging if you are running Elixir 1.10.0 - 1.10.2.
FWIW, I've just now tried this using Elixir 1.10.3 and I'm seeing the exact same issue that I originally reported.
@JayAndCatchFire I'm looking at your error log in more detail and it looks like you were encountering an error unrelated to the version of elixir being run. Do you know what mix env the code is running under (by default it is often test
)? Do you have any dependencies that aren't used in the test
environment?
It should be running under the dev
mix env, but I'll adjust my config to make it explicit and try again, just to be sure.
I tried adding the MIX_ENV
environment variable to the launch config, but it still acts the same way. Something is running, but not the local server. 🤷
Are you not getting the function DBConnection.past_event/3 is undefined or private
errors any more? Can you post a full log of the debug console output and the ElixirLS output?
That's correct. I'm not getting the function DBConnection.past_event/3 is undefined or private
errors anymore.
I checked the ElixirLS output and it doesn't output anything after I start the debugger.
The debug console output is as follows (db table names edited because it's my employer's code base):
Erlang version: "22"
Compiling 149 files (.ex)
2020-05-20T19:00:08.733Z [DEBUG] QUERY OK source="table1" db=1.1ms decode=2.9ms queue=1.2ms
SELECT m0."id", m1."location_id" FROM "table1" AS m0 INNER JOIN "table1_locations" AS m1 ON m1."table1_id" = m0."id" []
2020-05-20T19:00:52.934Z [ERROR] Handler {TelemetryMetricsPrometheus.Core.EventHandler, #PID<0.1831.0>, [:vm, :memory, :total]} has failed and has been detached. Class=:error
Reason=:undef
Stacktrace=[]
2020-05-20T19:00:52.935Z [ERROR] Handler {TelemetryMetricsPrometheus.Core.EventHandler, #PID<0.1831.0>, [:vm, :total_run_queue_lengths, :total]} has failed and has been detached. Class=:error
Reason=:undef
Stacktrace=[]
2020-05-20T19:00:52.935Z [ERROR] Handler {TelemetryMetricsPrometheus.Core.EventHandler, #PID<0.1831.0>, [:vm, :total_run_queue_lengths, :cpu]} has failed and has been detached. Class=:error
Reason=:undef
Stacktrace=[]
2020-05-20T19:00:52.936Z [ERROR] Handler {TelemetryMetricsPrometheus.Core.EventHandler, #PID<0.1831.0>, [:vm, :total_run_queue_lengths, :io]} has failed and has been detached. Class=:error
Reason=:undef
Stacktrace=[]
After that, it just sits there.
@JayAndCatchFire I noticed a similar problem with debugging phoenix app - when "startApps": true
was set in my launch config, the debugger would start but the http server would not.
Besides, telemetry handlers that are a private function does not work i interpreted mode. It's best to just add them to exclude list.
Environment
Troubleshooting
.elixir_ls
directory, then restart your editorReport
No matter what I do, I can't seem to get the debugger to act the same as when I run
mix phx.server
on the command line.Here's my
launch.json
file:I have set
startApps
totrue
because if I don't then I get errors about opencensus.My
config/dev.exs
has the following at the beginning, so the server starts on port 4000 and it kicks offnpm start
which runs my webpack-dev-server setup.However, when I run the debugger, NPM doesn't seem to get started and no server ever seems to come up on port 4000. I know that
config/dev.exs
is being run because when I add aIO.inspect
line at the top, I see my message printed in the Debug Console in VSCode. If I place aIO.inspect
line beneath it, that gets printed as well, so I know nothing is erroring out from that config call.I also always get errors related to my Oban and TelemetryMetricsPrometheus setup.
I've tried killing the code that sets up the telemetry library and while it stops these errors from happening, it doesn't fix the underlying problem where the server never starts. Also, there's clearly something happening since the debugging sessions doesn't end with an error or anything like that. And I see various processes/tasks/agents/genservers/whatever running in the callstack pane in VSCode. I'm not sure what to do to set this up properly.
FWIW, I'm able to set up a new boilerplate project using
phx_new
that will cooperate with the debugger relatively fine, although I do get these errors in the console: