devinus / poison

An incredibly fast, pure Elixir JSON library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Poison.encode_to_iodata!/1 missing in 4.x

smeevil opened this issue · comments

I was wondering what happend to the Poison.encode_to_iodata!/1 function and why it seems to have been removed ? (Also a CHANGELOG.md would help ;))

This function is used by lib/phoenix/controller.ex:342

 defp encode(content, template) do
    if encoder = Template.format_encoder(template) do
      encoder.encode_to_iodata!(content)
    else
      content
    end
  end

The recently release Postgrex v0.14.0 expects the JSON encoder to provide an encode_to_iodata!/1 function. Since this has been removed from Poison, it means that Poison cannot be used with Postgrex.

This is still important!

This happens also with the new myxql driver:

[error] GenServer #PID<0.898.0> terminating
** (UndefinedFunctionError) function Poison.encode_to_iodata!/1 is undefined or private
    (poison) Poison.encode_to_iodata!(["52", "52", "phoenix:live_reload", "phx_reply", %{response: %{}, status: :ok}])
    (phoenix) lib/phoenix/socket/serializers/v2_json_serializer.ex:21: Phoenix.Socket.V2.JSONSerializer.encode!/1
    (phoenix) lib/phoenix/socket.ex:782: Phoenix.Socket.encode_reply/2
    (phoenix) lib/phoenix/socket.ex:696: Phoenix.Socket.handle_in/4
    (phoenix) lib/phoenix/endpoint/cowboy2_handler.ex:83: Phoenix.Endpoint.Cowboy2Handler.websocket_handle/2
    (cowboy) c:/Users/<user>/<umbrella project path>/deps/cowboy/src/cowboy_websocket.erl:471: :cowboy_websocket.handler_call/6
    (cowboy) c:/Users/<user>/<umbrella project path>/deps/cowboy/src/cowboy_http.erl:233: :cowboy_http.loop/2
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

Or at least I'm not sure, but sure that function is not present in 4.0 and there is some problem with Cowboy, I guess