Skip to content

Commit 37dd730

Browse files
authored
Allow configuring debugExpressionTimeoutMs (#613)
* Allow configuring debugExpressionTimeoutMs Rather than a hard-coded timeout of 1_000 ms for watch expressions, add `debugExpressionTimeoutMs` to the launch.json configuration options. In the next version of vscode-elixir-ls `debugExpressionTimeoutMs` will be supported in the launch.json autocomplete, but if you are running a version of ElixirLS that supports it before then you can add the key manually. Example mix test launch.json entry that uses this to set a timeout of 30 seconds: ``` { "type": "mix_task", "name": "mix test", "request": "launch", "debugExpressionTimeoutMs": 30000, "task": "test", "taskArgs": [ "--trace" ], "startApps": true, "projectDir": "${workspaceRoot}", "requireFiles": [ "test/**/test_helper.exs", "test/**/*_test.exs" ] } ``` Fixes #525 * Fix test
1 parent db38656 commit 37dd730

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

apps/elixir_ls_debugger/lib/debugger/server.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ defmodule ElixirLS.Debugger.Server do
400400
request(_cmd, "evaluate", %{"expression" => expr} = _args),
401401
state = %__MODULE__{}
402402
) do
403-
timeout = 1_000
403+
timeout = Map.get(state.config, "debugExpressionTimeoutMs", 10_000)
404404
bindings = all_variables(state.paused_processes)
405405

406406
result = evaluate_code_expression(expr, bindings, timeout)

apps/elixir_ls_debugger/test/debugger_test.exs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ defmodule ElixirLS.Debugger.ServerTest do
509509
end
510510

511511
describe "Watch section" do
512-
defp gen_packet(expr) do
512+
defp gen_watch_expression_packet(expr) do
513513
%{
514514
"arguments" => %{
515515
"context" => "watch",
@@ -527,7 +527,7 @@ defmodule ElixirLS.Debugger.ServerTest do
527527

528528
Server.receive_packet(
529529
server,
530-
gen_packet("1 + 2 + 3 + 4")
530+
gen_watch_expression_packet("1 + 2 + 3 + 4")
531531
)
532532

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

542542
Server.receive_packet(
543543
server,
544-
gen_packet("1 = 2")
544+
gen_watch_expression_packet("1 = 2")
545545
)
546546

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

557557
Server.receive_packet(
558558
server,
559-
gen_packet("Process.exit(self(), :normal)")
559+
gen_watch_expression_packet("Process.exit(self(), :normal)")
560560
)
561561

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

572572
Server.receive_packet(
573573
server,
574-
gen_packet("throw(:goodmorning_bug)")
574+
gen_watch_expression_packet("throw(:goodmorning_bug)")
575575
)
576576

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

584584
test "Evaluate expression which has long execution", %{server: server} do
585585
Server.receive_packet(server, initialize_req(1, %{}))
586+
assert_receive(response(_, 1, "initialize", %{"supportsConfigurationDoneRequest" => true}))
587+
588+
Server.receive_packet(
589+
server,
590+
launch_req(2, %{
591+
"request" => "launch",
592+
"type" => "mix_task",
593+
"task" => "test",
594+
"projectDir" => File.cwd!(),
595+
"debugExpressionTimeoutMs" => 500
596+
})
597+
)
598+
599+
assert_receive(response(_, 2, "launch", %{}), 5000)
586600

587601
Server.receive_packet(
588602
server,
589-
gen_packet(":timer.sleep(10_000)")
603+
gen_watch_expression_packet(":timer.sleep(10_000)")
590604
)
591605

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

0 commit comments

Comments
 (0)