Flow exited with strange FunctionClauseException

Hi,

I’m playing with Flow and I’m trying to make my code raise an exception to test the behaviour of my parent GenServer.
Thus, I ran a Enum.random on an empty array. I can see that the GenServer started by Flow exited (at least 2 of them) with this exception.
But I can also see that a 3rd one is exiting but not because of my exception. This one is exiting because of:

** (FunctionClauseError) no function clause matching in Flow.Coordinator.handle_info/2

Is it a normal behaviour, or a bug? I’m asking because it seems weird (at least to me) that because of my exception, one of the Flow servers exited with a FunctionClauseError.

If it is normal, can someone explain me why it is behaving this way?

Here is the full log I have when it raises the exception:

[error] GenServer #PID<0.472.0> terminating
** (Enum.EmptyError) empty error
    (elixir) lib/enum.ex:1684: Enum.random/1
    (myproject) lib/myproject/offers/offers_manager.ex:193: anonymous fn/2 in MyProject.OffersManager.retrieve_best_place/1
    (flow) lib/flow/materialize.ex:539: anonymous fn/4 in Flow.Materialize.mapper/2
    (flow) lib/flow/materialize.ex:508: Flow.Materialize."-mapper_ops/1-lists^foldl/2-1-"/3
    (flow) lib/flow/materialize.ex:508: anonymous fn/5 in Flow.Materialize.mapper_ops/1
    (flow) lib/flow/map_reducer.ex:50: Flow.MapReducer.handle_events/3
    lib/gen_stage.ex:2408: GenStage.consumer_dispatch/7
    lib/gen_stage.ex:2531: GenStage.take_pc_events/3
    (stdlib) gen_server.erl:601: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:667: :gen_server.handle_msg/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: {:"$gen_consumer", {#PID<0.457.0>, #Reference<0.0.1.3610>}, [{%MyProject.User{address_state: "dfsf", maxDistKm: 500, appToken: "4616d9a9b15755ec254452b4ecdb7b505ffef1f3e2f2205b3b9ad4bd54bd947e", last_lat: 48.905455171805, name: "Fabien Henon", image: "image.php?type=avatar&id=12&token=1461183061#1461183061", __meta__: #Ecto.Schema.Metadata<:loaded, "user">, sessionKey: "588f9fd52c5b2", sessionType: "mix", address_line1: "dsf", address_city: "sdfsf", lastVoteNotif: #<DateTime(2014-11-26T00:18:02Z Etc/UTC)>, sessionDate: #<DateTime(2017-01-30T21:29:26Z Etc/UTC)>, address_line2: "s", lastConnection: #<DateTime(2017-01-30T21:19:33Z Etc/UTC)>, address_country: "France", lastActionDate: #<DateTime(2016-12-29T22:07:13Z Etc/UTC)>, address_zip: "92270", passwordKey: "5289eeffa0f86", city: "Ma ville  moi", email: "thebasher@hotmail.fr", real_name: "Fab", subscriptions: #Ecto.Association.NotLoaded<association :subscriptions is not loaded>, birthdate: ~D[1989-03-26], password: "5ebe2294ecd0e0f08eab7690d2a6ee69", subscriptionConsumerToken: "cus_9qwULEwqiKNn2A", facebookID: "61d336f5d335bee1f347344cd7c97d68", lang: "fr", last_lon: 2.2657097748325, validated: true, currAction: 1, id: 12, address_country_code: "FR", facebookEmail: "thebasher@hotmail.fr", connected: true, passwordKeyDate: #<DateTime(2013-11-18T14:42:07Z Etc/UTC)>, pushPlatform: "ios", registrationDate: #<DateTime(2013-11-17T19:43:00Z Etc/UTC)>, description: "Je suis informaticien\r\nQui cre sa bote\r\nEh oui\r\n\r\nOui oui :)", currPlace_id: 15, validationKey: "52890e34df304"}, %MyProject.Subscription{__meta__: #Ecto.Schema.Metadata<:loaded, "subscriptions">, end_date: nil, id: 41, inserted_at: #<DateTime(2017-01-24T07:23:07Z Etc/UTC)>, plan: "offer_fr", quantity: 1, real_end_date: #<DateTime(2017-02-26T07:23:05Z Etc/UTC)>, start_date: #<DateTime(2017-01-24T07:23:05Z Etc/UTC)>, subscription_token: "sub_9zNO22qRCr3ds5", trial_days: nil, updated_at: #<DateTime(2017-01-24T07:23:07Z Etc/UTC)>, user: #Ecto.Association.NotLoaded<association :user is not loaded>, user_id: 12}}]}
State: {%{#Reference<0.0.1.3608> => nil, #Reference<0.0.1.3609> => nil, #Reference<0.0.1.3610> => nil, #Reference<0.0.1.3611> => nil, #Reference<0.0.1.3612> => nil, #Reference<0.0.1.3613> => nil, #Reference<0.0.1.3614> => nil, #Reference<0.0.1.3615> => nil, #Reference<0.0.1.3616> => nil, #Reference<0.0.1.3617> => nil}, %{active: [#Reference<0.0.1.3617>, #Reference<0.0.1.3616>, #Reference<0.0.1.3615>, #Reference<0.0.1.3614>, #Reference<0.0.1.3613>, #Reference<0.0.1.3612>, #Reference<0.0.1.3611>, #Reference<0.0.1.3610>, #Reference<0.0.1.3609>], consumers: [#Reference<0.0.1.3655>], done?: false, producers: %{#Reference<0.0.1.3608> => #PID<0.455.0>, #Reference<0.0.1.3609> => #PID<0.456.0>, #Reference<0.0.1.3610> => #PID<0.457.0>, #Reference<0.0.1.3611> => #PID<0.458.0>, #Reference<0.0.1.3612> => #PID<0.459.0>, #Reference<0.0.1.3613> => #PID<0.460.0>, #Reference<0.0.1.3614> => #PID<0.461.0>, #Reference<0.0.1.3615> => #PID<0.462.0>, #Reference<0.0.1.3616> => #PID<0.463.0>, #Reference<0.0.1.3617> => #PID<0.464.0>}, trigger: #Function<2.31322697/4 in Flow.Window.Global.materialize/5>}, {7, 10}, [], #Function<33.109138938/4 in Flow.Materialize.mapper_ops/1>}
[error] GenServer #PID<0.475.0> terminating
** (Enum.EmptyError) empty error
    (elixir) lib/enum.ex:1684: Enum.random/1
    (myproject) lib/myproject/offers/offers_manager.ex:193: anonymous fn/2 in MyProject.OffersManager.retrieve_best_place/1
    (flow) lib/flow/materialize.ex:539: anonymous fn/4 in Flow.Materialize.mapper/2
    (flow) lib/flow/materialize.ex:508: Flow.Materialize."-mapper_ops/1-lists^foldl/2-1-"/3
    (flow) lib/flow/materialize.ex:508: anonymous fn/5 in Flow.Materialize.mapper_ops/1
    (flow) lib/flow/map_reducer.ex:50: Flow.MapReducer.handle_events/3
    lib/gen_stage.ex:2408: GenStage.consumer_dispatch/7
    lib/gen_stage.ex:2531: GenStage.take_pc_events/3
    (stdlib) gen_server.erl:601: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:667: :gen_server.handle_msg/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: {:DOWN, #Reference<0.0.1.3655>, :process, #PID<0.472.0>, {%Enum.EmptyError{message: "empty error"}, [{Enum, :random, 1, [file: 'lib/enum.ex', line: 1684]}, {MyProject.OffersManager, :"-retrieve_best_place/1-fun-1-", 2, [file: 'lib/myproject/offers/offers_manager.ex', line: 193]}, {Flow.Materialize, :"-mapper/2-fun-4-", 4, [file: 'lib/flow/materialize.ex', line: 539]}, {Flow.Materialize, :"-mapper_ops/1-lists^foldl/2-1-", 3, [file: 'lib/flow/materialize.ex', line: 508]}, {Flow.Materialize, :"-mapper_ops/1-fun-3-", 5, [file: 'lib/flow/materialize.ex', line: 508]}, {Flow.MapReducer, :handle_events, 3, [file: 'lib/flow/map_reducer.ex', line: 50]}, {GenStage, :consumer_dispatch, 7, [file: 'lib/gen_stage.ex', line: 2408]}, {GenStage, :take_pc_events, 3, [file: 'lib/gen_stage.ex', line: 2531]}, {:gen_server, :try_dispatch, 4, [file: 'gen_server.erl', line: 601]}, {:gen_server, :handle_msg, 5, [file: 'gen_server.erl', line: 667]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}}
State: {%{#Reference<0.0.1.3648> => nil, #Reference<0.0.1.3649> => nil, #Reference<0.0.1.3650> => nil, #Reference<0.0.1.3651> => nil, #Reference<0.0.1.3652> => nil, #Reference<0.0.1.3653> => nil, #Reference<0.0.1.3654> => nil, #Reference<0.0.1.3656> => nil, #Reference<0.0.1.3657> => nil}, %{active: [], consumers: [#Reference<0.0.2.1517>, #Reference<0.0.2.1514>], done?: true, producers: %{#Reference<0.0.1.3648> => #PID<0.465.0>, #Reference<0.0.1.3649> => #PID<0.466.0>, #Reference<0.0.1.3650> => #PID<0.467.0>, #Reference<0.0.1.3651> => #PID<0.468.0>, #Reference<0.0.1.3652> => #PID<0.469.0>, #Reference<0.0.1.3653> => #PID<0.470.0>, #Reference<0.0.1.3654> => #PID<0.471.0>, #Reference<0.0.1.3656> => #PID<0.473.0>, #Reference<0.0.1.3657> => #PID<0.474.0>}, trigger: #Function<3.92340763/4 in Flow.Window.Count.materialize/5>}, {0, 1}, {0, 100, ""}, #Function<2.92340763/4 in Flow.Window.Count.materialize/5>}
[error] GenServer #PID<0.452.0> terminating
** (FunctionClauseError) no function clause matching in Flow.Coordinator.handle_info/2
    (flow) lib/flow/coordinator.ex:69: Flow.Coordinator.handle_info({:EXIT, #PID<0.453.0>, :shutdown}, %{intermediary: [{#PID<0.476.0>, []}, {#PID<0.477.0>, []}], parent_ref: #Reference<0.0.2.1520>, producers: [#PID<0.454.0>], refs: [#Reference<0.0.2.1518>, #Reference<0.0.2.1519>], supervisor: #PID<0.453.0>})
    (stdlib) gen_server.erl:601: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:667: :gen_server.handle_msg/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: {:EXIT, #PID<0.453.0>, :shutdown}
State: %{intermediary: [{#PID<0.476.0>, []}, {#PID<0.477.0>, []}], parent_ref: #Reference<0.0.2.1520>, producers: [#PID<0.454.0>], refs: [#Reference<0.0.2.1518>, #Reference<0.0.2.1519>], supervisor: #PID<0.453.0>}
1 Like

Can you show the code you used to generate this error?

1 Like

Yes, please report a bug on elixir-lang/flow and include a way to reproduce the error. :slight_smile:

1 Like

Alright, this issue has been created :wink:

1 Like