diff --git a/CHANGELOG.md b/CHANGELOG.md index 39d62081b..ae762f4dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ## 1.1.2 -* Remove 'failed to insert a metric' stalker warning [#849](https://github.com/membraneframework/membrane_core/pull/849) + * Remove 'failed to insert a metric' stalker warning [#849](https://github.com/membraneframework/membrane_core/pull/849) ## 1.1.1 * Fix 'table identifier does not refer to an existing ETS table' error when inserting metrics into the observability ETS. [#835](https://github.com/membraneframework/membrane_core/pull/835) diff --git a/lib/membrane/core/element/action_handler.ex b/lib/membrane/core/element/action_handler.ex index d6027870d..4a4ec1aed 100644 --- a/lib/membrane/core/element/action_handler.ex +++ b/lib/membrane/core/element/action_handler.ex @@ -229,11 +229,12 @@ defmodule Membrane.Core.Element.ActionHandler do @impl CallbackHandler def handle_action( {:demand, {pad_ref, size}}, - _cb, + cb, _params, %State{type: type} = state ) when is_pad_ref(pad_ref) and is_demand_size(size) and type in [:sink, :filter, :endpoint] do + :ok = maybe_warn_on_demand_action(pad_ref, size, cb, state) delay_supplying_demand(pad_ref, size, state) end @@ -481,4 +482,17 @@ defmodule Membrane.Core.Element.ActionHandler do end defp handle_outgoing_event(_pad_ref, _event, state), do: state + + defp maybe_warn_on_demand_action(pad_ref, demand_size, callback, state) do + if PadModel.get_data!(state, pad_ref, :end_of_stream?) do + Membrane.Logger.warning(""" + Action :demand with value #{inspect(demand_size)} for pad #{inspect(pad_ref)} was returned \ + from callback #{inspect(callback)}, but stream on this pad has already ended, callback \ + c:handle_end_of_stream/3 for this pad has been called and no more buffers will arrive on \ + this pad. + """) + end + + :ok + end end