Skip to content

Commit 63d2c63

Browse files
committed
Improve timeout UX in the conformance runner
It now spits out a nice error message.
1 parent 68a4a9f commit 63d2c63

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

conformance/protobuf/runner.ex

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Conformance.Protobuf.Runner do
22
@moduledoc false
33

4-
@stdin_read_timeout 5000
4+
@stdin_read_timeout 3000
55

66
@spec main() :: :ok
77
def main() do
@@ -51,7 +51,12 @@ defmodule Conformance.Protobuf.Runner do
5151

5252
defp read_bytes(device, count, timeout) do
5353
task = Task.async(fn -> IO.binread(device, count) end)
54-
Task.await(task, timeout)
54+
55+
case Task.yield(task, timeout) || Task.shutdown(task) do
56+
{:ok, bytes} -> bytes
57+
{:exit, reason} -> raise "failed to read bytes from stdio: #{inspect(reason)}"
58+
nil -> raise "failed to read bytes from stdio, timed out"
59+
end
5560
end
5661

5762
defp handle_encoded_request(encoded_request) do

0 commit comments

Comments
 (0)