Trouble deploying to Heroku with react-phoenix

I’m using react-phoenix in a project. I was having a beast trying to get it working on my local env. Eventually, I managed, but when I deployed to Heroku I got the same error I had resolved locally. This is the error from the log:

2017-08-19T13:52:40.719864+00:00 app[web.1]: 13:52:40.718 [error] GenServer #PID<0.274.0> terminating
2017-08-19T13:52:40.719869+00:00 app[web.1]: ** (MatchError) no match of right hand side value: {:error, {:function_clause, [{Porcelain, :spawn_shell, [nil, [in: :receive, out: {:send, #PID<0.275.0>}]], [file: 'lib/porcelain.ex', line: 241]}, {StdJsonIo.Worker, :init, 1, [file: 'lib/std_json_io/worker.ex', line: 12]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 328]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}}
2017-08-19T13:52:40.719870+00:00 app[web.1]:     src/poolboy.erl:275: :poolboy.new_worker/1
2017-08-19T13:52:40.719870+00:00 app[web.1]:     src/poolboy.erl:296: :poolboy.prepopulate/3
2017-08-19T13:52:40.719871+00:00 app[web.1]:     src/poolboy.erl:145: :poolboy.init/3
2017-08-19T13:52:40.719872+00:00 app[web.1]:     (stdlib) gen_server.erl:328: :gen_server.init_it/6
2017-08-19T13:52:40.719872+00:00 app[web.1]:     (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
2017-08-19T13:52:40.719875+00:00 app[web.1]: Last message: {:EXIT, #PID<0.273.0>, {{:badmatch, {:error, {:function_clause, [{Porcelain, :spawn_shell, [nil, [in: :receive, out: {:send, #PID<0.275.0>}]], [file: 'lib/porcelain.ex', line: 241]}, {StdJsonIo.Worker, :init, 1, [file: 'lib/std_json_io/worker.ex', line: 12]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 328]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}}}, [{:poolboy, :new_worker, 1, [file: 'src/poolboy.erl', line: 275]}, {:poolboy, :prepopulate, 3, [file: 'src/poolboy.erl', line: 296]}, {:poolboy, :init, 3, [file: 'src/poolboy.erl', line: 145]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 328]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}}
2017-08-19T13:52:40.719899+00:00 app[web.1]: 13:52:40.719 [info] Application react_phoenix exited: ReactPhoenix.Application.start(:normal, []) returned an error: shutdown: failed to start child: ReactPhoenix.ReactIo
2017-08-19T13:52:40.719900+00:00 app[web.1]:     ** (EXIT) shutdown: failed to start child: ReactPhoenix.ReactIo.Pool
2017-08-19T13:52:40.719901+00:00 app[web.1]:         ** (EXIT) an exception was raised:
2017-08-19T13:52:40.719903+00:00 app[web.1]:             ** (MatchError) no match of right hand side value: {:error, {:function_clause, [{Porcelain, :spawn_shell, [nil, [in: :receive, out: {:send, #PID<0.275.0>}]], [file: 'lib/porcelain.ex', line: 241]}, {StdJsonIo.Worker, :init, 1, [file: 'lib/std_json_io/worker.ex', line: 12]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 328]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}}
2017-08-19T13:52:40.719904+00:00 app[web.1]:                 src/poolboy.erl:275: :poolboy.new_worker/1
2017-08-19T13:52:40.719904+00:00 app[web.1]:                 src/poolboy.erl:296: :poolboy.prepopulate/3
2017-08-19T13:52:40.719905+00:00 app[web.1]:                 src/poolboy.erl:145: :poolboy.init/3
2017-08-19T13:52:40.719906+00:00 app[web.1]:                 (stdlib) gen_server.erl:328: :gen_server.init_it/6
2017-08-19T13:52:40.719907+00:00 app[web.1]:                 (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
2017-08-19T13:52:42.253486+00:00 app[web.1]: {"Kernel pid terminated",application_controller,"{application_start_failure,react_phoenix,{{shutdown,{failed_to_start_child,'Elixir.ReactPhoenix.ReactIo',{shutdown,{failed_to_start_child,'Elixir.ReactPhoenix.ReactIo.Pool',{{badmatch,{error,{function_clause,[{'Elixir.Porcelain',spawn_shell,[nil,[{in,'receive'},{out,{send,<0.275.0>}}]],[{file,\"lib/porcelain.ex\"},{line,241}]},{'Elixir.StdJsonIo.Worker',init,1,[{file,\"lib/std_json_io/worker.ex\"},{line,12}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,328}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,247}]}]}}},[{poolboy,new_worker,1,[{file,\"src/poolboy.erl\"},{line,275}]},{poolboy,prepopulate,3,[{file,\"src/poolboy.erl\"},{line,296}]},{poolboy,init,3,[{file,\"src/poolboy.erl\"},{line,145}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,328}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,247}]}]}}}}},{'Elixir.ReactPhoenix.Application',start,[normal,[]]}}}"}
2017-08-19T13:52:42.254119+00:00 app[web.1]: Kernel pid terminated (application_controller) ({application_start_failure,react_phoenix,{{shutdown,{failed_to_start_child,'Elixir.ReactPhoenix.ReactIo',{shutdown,{failed_to_start_child,'Elixir.ReactP

When I ran into it on dev, I added override to the dependency in mix.exs:

      {:react_phoenix, "~> 0.4.3", override: true}

Here are the rest of my deps:

  defp deps do
      {:phoenix, "~> 1.3.0"},
      {:phoenix_pubsub, "~> 1.0"},
      {:phoenix_ecto, "~> 3.2"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 2.10"},
      {:phoenix_live_reload, "~> 1.0", only: :dev},
      {:gettext, "~> 0.11"},
      {:cowboy, "~> 1.0"},
      {:ueberauth, "~> 0.4"},
      {:ueberauth_instagram, "~> 0.2.0"},
      {:guardian, "~> 0.14"},
      {:elixtagram, "~> 0.6.0"},
      {:hackney, "~> 1.9.0", override: true},
      {:cachex, "~> 2.1"},
      {:bodyguard, "~> 2.1"},
      {:react_phoenix, "~> 0.4.3", override: true}

I’m using Phoenix 1.3 with Elixir 1.4.2 and OTP 19. Any idea how to debug this?

It sounds like Porcelain tried to launch an external command and the command failed to load or did not exist.

/me does not use react or any of its Elixir libs though

I haven’t used it but from what I recall react-phoenix is trying to launch a node process port that it will use to do server-side rendering.

Did you set the config like the docs mention, so it looks in the right path (in assets) for the node_modules/.bin for react-stdio?

react_stdio_path: Path.join(["assets", "node_modules", ".bin", "react-stdio"])

You might try just running that program in your dyno to see if you get an error, something like heroku run assets/node_modules/.bin/react-stdio.

@OvermindDL1 @jeremyjh thanks. Actually, I’m not using the server side rendering. This issue seems to happen when I include the react-jhoenix javascript dependency in package.json:

"react-phoenix": "file:../deps/react_phoenix"

I’m pretty sure it’s something to do with its dependencies.

In the and, I axed the lib, wrote my own helper, and included its js file in assets/js, and everything works as expected.

1 Like