{"action":"closed","issue":{"url":"https://api.github.com/repos/elixir-lang/elixir/issues/6247","repository_url":"https://api.github.com/repos/elixir-lang/elixir","labels_url":"https://api.github.com/repos/elixir-lang/elixir/issues/6247/labels{/name}","comments_url":"https://api.github.com/repos/elixir-lang/elixir/issues/6247/comments","events_url":"https://api.github.com/repos/elixir-lang/elixir/issues/6247/events","html_url":"https://github.com/elixir-lang/elixir/issues/6247","id":237696012,"number":6247,"title":"`restart: :transient` supervisor does not restart async stream tasks","user":{"login":"myronmarston","id":49391,"avatar_url":"https://avatars3.githubusercontent.com/u/49391?v=3","gravatar_id":"","url":"https://api.github.com/users/myronmarston","html_url":"https://github.com/myronmarston","followers_url":"https://api.github.com/users/myronmarston/followers","following_url":"https://api.github.com/users/myronmarston/following{/other_user}","gists_url":"https://api.github.com/users/myronmarston/gists{/gist_id}","starred_url":"https://api.github.com/users/myronmarston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myronmarston/subscriptions","organizations_url":"https://api.github.com/users/myronmarston/orgs","repos_url":"https://api.github.com/users/myronmarston/repos","events_url":"https://api.github.com/users/myronmarston/events{/privacy}","received_events_url":"https://api.github.com/users/myronmarston/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-06-21T23:53:01Z","updated_at":"2017-06-22T09:43:48Z","closed_at":"2017-06-22T09:43:48Z","body":"### Environment\r\n\r\n* Elixir & Erlang versions (elixir --version): \r\n\r\n```\r\nErlang/OTP 19 [erts-8.3] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]\r\n\r\nElixir 1.4.2\r\n```\r\n\r\n* Operating system: \r\n\r\nOS X 10.11.4\r\n\r\n### Current behavior\r\n\r\n``` elixir\r\ndefmodule AsyncStreamTest do\r\n  use ExUnit.Case, async: true\r\n\r\n  test \"async stream tasks started under a `restart: :transient` supervisor should get retried\" do\r\n    {:ok, task_sup} = Task.Supervisor.start_link(restart: :transient)\r\n    {:ok, failure_toggle} = Agent.start_link(fn -> true end)\r\n\r\n    stream =\r\n      Task.Supervisor.async_stream(task_sup, 1..2, fn i ->\r\n        should_fail? = Agent.get_and_update(failure_toggle, fn fail? -> {fail?, !fail?} end)\r\n        if should_fail?, do: raise \"boom\"\r\n        i * 2\r\n      end)\r\n\r\n    assert Enum.to_list(stream) == [{:ok, 2}, {:ok, 4}]\r\n  end\r\nend\r\n```\r\n\r\nThis test fails like so:\r\n\r\n```\r\nAsyncStreamTest\r\n  * test async stream tasks started under a `restart: :transient` supervisor should get retried (0.00ms)\r\n\r\n  1) test async stream tasks started under a `restart: :transient` supervisor should get retried (AsyncStreamTest)\r\n     test/async_stream_test.exs:4\r\n     ** (EXIT from #PID<0.264.0>) an exception was raised:\r\n         ** (RuntimeError) boom\r\n             test/async_stream_test.exs:11: anonymous fn/2 in AsyncStreamTest.test async stream tasks started under a `restart: :transient` supervisor should get retried/1\r\n             (elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2\r\n             (elixir) lib/task/supervised.ex:36: Task.Supervised.reply/5\r\n             (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3\r\n\r\n     The following output was logged:\r\n     16:47:52.903 [error] Task #PID<0.268.0> started from #PID<0.267.0> terminating\r\n     ** (RuntimeError) boom\r\n         test/async_stream_test.exs:11: anonymous fn/2 in AsyncStreamTest.test async stream tasks started under a `restart: :transient` supervisor should get retried/1\r\n         (elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2\r\n         (elixir) lib/task/supervised.ex:36: Task.Supervised.reply/5\r\n         (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3\r\n     Function: &:erlang.apply/2\r\n         Args: [#Function<1.41996171/1 in AsyncStreamTest.test async stream tasks started under a `restart: :transient` supervisor should get retried/1>, [1]]\r\n     16:47:52.908 [error] GenServer #PID<0.265.0> terminating\r\n     ** (RuntimeError) boom\r\n         test/async_stream_test.exs:11: anonymous fn/2 in AsyncStreamTest.test async stream tasks started under a `restart: :transient` supervisor should get retried/1\r\n         (elixir) lib/task/supervised.ex:85: Task.Supervised.do_apply/2\r\n         (elixir) lib/task/supervised.ex:36: Task.Supervised.reply/5\r\n         (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3\r\n     Last message: {:EXIT, #PID<0.264.0>, {%RuntimeError{message: \"boom\"}, [{AsyncStreamTest, :\"-test async stream tasks started under a `restart: :transient` supervisor should get retried/1-fun-2-\", 2, [file: 'test/async_stream_test.exs', line: 11]}, {Task.Supervised, :do_apply, 2, [file: 'lib/task/supervised.ex', line: 85]}, {Task.Supervised, :reply, 5, [file: 'lib/task/supervised.ex', line: 36]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}}\r\n```\r\n\r\n### Expected behavior\r\n\r\nI'd expect the tasks to get retried by the supervisor.  Initially, I went looking at the docs for `Task.async_stream` to see if there is any kind of retry option, but did not find one.  Then I found `Task.Supervisor.async_stream`, and figured that supervisors are the idiomatic Elixir/OTP way to manage restarts/retries, so I expected to be able to compose a `restart: :transient` task supervisor with an async stream and get retries.\r\n"}}
{"actor":{"display_login":"josevalim"}}