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

Allow configuring debugExpressionTimeoutMs #613

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/elixir_ls_debugger/lib/debugger/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ defmodule ElixirLS.Debugger.Server do
request(_cmd, "evaluate", %{"expression" => expr} = _args),
state = %__MODULE__{}
) do
timeout = 1_000
timeout = Map.get(state.config, "debugExpressionTimeoutMs", 10_000)
bindings = all_variables(state.paused_processes)

result = evaluate_code_expression(expr, bindings, timeout)
Expand Down
26 changes: 20 additions & 6 deletions apps/elixir_ls_debugger/test/debugger_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ defmodule ElixirLS.Debugger.ServerTest do
end

describe "Watch section" do
defp gen_packet(expr) do
defp gen_watch_expression_packet(expr) do
%{
"arguments" => %{
"context" => "watch",
Expand All @@ -527,7 +527,7 @@ defmodule ElixirLS.Debugger.ServerTest do

Server.receive_packet(
server,
gen_packet("1 + 2 + 3 + 4")
gen_watch_expression_packet("1 + 2 + 3 + 4")
)

assert_receive(%{"body" => %{"result" => "10"}}, 1000)
Expand All @@ -541,7 +541,7 @@ defmodule ElixirLS.Debugger.ServerTest do

Server.receive_packet(
server,
gen_packet("1 = 2")
gen_watch_expression_packet("1 = 2")
)

assert_receive(%{"body" => %{"result" => result}}, 1000)
Expand All @@ -556,7 +556,7 @@ defmodule ElixirLS.Debugger.ServerTest do

Server.receive_packet(
server,
gen_packet("Process.exit(self(), :normal)")
gen_watch_expression_packet("Process.exit(self(), :normal)")
)

assert_receive(%{"body" => %{"result" => result}}, 1000)
Expand All @@ -571,7 +571,7 @@ defmodule ElixirLS.Debugger.ServerTest do

Server.receive_packet(
server,
gen_packet("throw(:goodmorning_bug)")
gen_watch_expression_packet("throw(:goodmorning_bug)")
)

assert_receive(%{"body" => %{"result" => result}}, 1000)
Expand All @@ -583,10 +583,24 @@ defmodule ElixirLS.Debugger.ServerTest do

test "Evaluate expression which has long execution", %{server: server} do
Server.receive_packet(server, initialize_req(1, %{}))
assert_receive(response(_, 1, "initialize", %{"supportsConfigurationDoneRequest" => true}))

Server.receive_packet(
server,
launch_req(2, %{
"request" => "launch",
"type" => "mix_task",
"task" => "test",
"projectDir" => File.cwd!(),
"debugExpressionTimeoutMs" => 500
})
)

assert_receive(response(_, 2, "launch", %{}), 5000)

Server.receive_packet(
server,
gen_packet(":timer.sleep(10_000)")
gen_watch_expression_packet(":timer.sleep(10_000)")
)

assert_receive(%{"body" => %{"result" => result}}, 1100)
Expand Down