livebook-dev / kino

Client-driven interactive widgets for Livebook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`handle_call` from the `Kino.JS.Live` behaviour cannot return `:noreply`

Janix4000 opened this issue · comments

My Kino module uses:

use Kino.JS, assets_path: "lib/assets/player"
use Kino.JS.Live

and "implements" handle_call function:

  @impl true
  def handle_call({:create, framerate}, from, ctx) do
    payload = %{framerate: framerate, from: from}

    broadcast_event(ctx, "create", payload)

    {:noreply, ctx}
  end

and replies in other callback:

  def handle_event("jmuxer_ready", from, ctx) do
    GenServer.reply(from, {:ok, :player_created})
    {:noreply, assign(ctx, jmuxer_ready: true)}
  end

However, I cannot return :noreply from the handle_call callback despite the documentation:

[error] GenServer #PID<0.482.0> terminating
** (MatchError) no match of right hand side value: {:noreply, %Kino.JS.Live.Context{assigns: %{clients: ["suokrbya"], jmuxer_ready: false, type: :both}, origin: nil, __private__: %{client_ids_with_pid: %{"kea4nx2qfe3m2xeiaoxoagt5iwz5ahru" => #PID<11798.1126.0>}, monitors_with_client_id: %{#Reference<0.588131328.1499463684.243371> => "kea4nx2qfe3m2xeiaoxoagt5iwz5ahru"}, ref: "7zwxud775xferh3buuko4zchfjqzlrbd"}}}
    (kino 0.8.1) lib/kino/js/live/server.ex:50: Kino.JS.Live.Server.handle_call/3
    (stdlib 4.2) gen_server.erl:1149: :gen_server.try_handle_call/4
    (stdlib 4.2) gen_server.erl:1178: :gen_server.handle_msg/6
    (stdlib 4.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message (from #PID<0.515.0>): {:create, 25.0}

I think it is due to these lines.

Is this considered a bug?

A PR is welcome!

A PR is welcome!

Done #274

Closed in #274.