Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expected :action/2 to return a Plug.Conn error in Phoenix controller

I am trying to get Hyperledger working in a replicated private pool mode. There are no responses in their forum and hence the question here. Moreover the question is purely about a technical error.

Hyperledger uses Phoenix, Cowboy, Elixir, Ecto, Erlang, Postgre SQL, Node.js, etc. The primary node processes the request, inserts a row into couple of tables and broadcasts a message to the secondary node. The secondary node does something similar and sends a message back to the primary node to continue processing. Here is where the problems start. The primary node now tries to read rows it inserted earlier but gets a nil result. Thereafter the following exception is thrown.

** (exit) an exception was raised:
    ** (RuntimeError) expected :action/2 to return a Plug.Conn
        (hyperledger) web/controllers/log_entry_controller.ex:1: Hyperledger.LogEntryController.phoenix_controller_pipeline/2
        (hyperledger) lib/phoenix/router.ex:297: Hyperledger.Router.dispatch/2
        (hyperledger) lib/phoenix/router.ex:2: Hyperledger.Router.call/2
        (hyperledger) lib/hyperledger/endpoint.ex:1: Hyperledger.Endpoint.phoenix_endpoint_pipeline/1
        (hyperledger) lib/plug/debugger.ex:90: Hyperledger.Endpoint."call (overridable 3)"/2
        (hyperledger) lib/phoenix/endpoint/render_errors.ex:34: Hyperledger.Endpoint.call/2
        (phoenix) lib/phoenix/endpoint/cowboy_handler.ex:50: Phoenix.Endpoint.CowboyHandler.upgrade/4
        (cowboy) src/cowboy_protocol.erl:435: :cowboy_protocol.execute/4

Why is the primary node unable to read something that it inserted before the broadcast was sent to the secondary node. I am suspecting something to do with a stale database connection or similar here. Any help would be greatly appreciated. Please let me know if I should share additional information.

like image 657
Sriman Avatar asked Jan 07 '23 21:01

Sriman


1 Answers

You have an action in your controller that is not returning the conn. All actions must receive conn and return the updated conn.

like image 176
José Valim Avatar answered Jan 19 '23 01:01

José Valim