holsee / chroxy

Headless Chrome as a Service

Home Page:https://hex.pm/packages/chroxy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Protocol.UndefinedError on ChromeServer termination

holsee opened this issue · comments

When running Chroxy with root permissions (which is not supported see the Dockerfile for example how to avoid doing so), you can see the issue with ChromeServer process termination reason being logged as follows:

web_1       | 12:33:59.391 pid=<0.2084.0> module=gen_server line=888 [error] GenServer #PID<0.2084.0> terminating
web_1       | ** (Protocol.UndefinedError) protocol String.Chars not implemented for {{:exit_status, 4}, {:gen_server, :call, [:exec, {:port, {{:run, '/usr/bin/google-chrome --headless --disable-gpu --disable-translate --disable-extensions --disable-background-networking --safebrowsing-disable-auto-update --enable-logging --disable-sync --metrics-recording-only --disable-default-apps --mute-audio --no-first-run --no-sandbox --incognito --remote-debugging-port=9222 --crash-dumps-dir= --v=0', [:pty, :stderr, :stdin, :stdout]}, :link, false}}, 30000]}}. This protocol is implemented for: Postgrex.Query, Postgrex.Copy, Decimal, Integer, Float, Version.Requirement, Time, NaiveDateTime, DateTime, Date, BitString, List, Atom, Version, URI
web_1       |     (elixir) /usr/local/src/elixir/lib/elixir/lib/string/chars.ex:3: String.Chars.impl_for!/1
web_1       |     (elixir) /usr/local/src/elixir/lib/elixir/lib/string/chars.ex:22: String.Chars.to_string/1
web_1       |     (chroxy) lib/chroxy/chrome_server.ex:126: Chroxy.ChromeServer.terminate/2
web_1       |     (stdlib) gen_server.erl:673: :gen_server.try_terminate/3
web_1       |     (stdlib) gen_server.erl:858: :gen_server.terminate/10
web_1       |     (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
web_1       | Last message: :launch

https://github.com/elixir-lang/elixir/blob/v1.8.1/lib/elixir/lib/gen_server.ex#L627
Shows that a tuple needs to be supported as a possible terminate reason. I suggest an inspect call to wrap the reason in the log message.

@holsee Hi, can i work on this issue?
I am new to github so would be great if i could get a chance to work on some beginner friendly issue. :)

@ravi0213 it looks like #38 beat you to the punch. You are more than welcome to work on anything you wish