elixir-grpc / grpc

An Elixir implementation of gRPC
https://hex.pm/packages/grpc
Apache License 2.0
1.36k stars 210 forks source link

Error Starting GRPC.Server.Supervisor with Phoenix 1.7.0-rc-0 #287

Closed cdesch closed 1 year ago

cdesch commented 1 year ago

Describe the bug Following the helloworld example and adding it to a Phoenix 1.7.0-rc-0 application, I get the following Error:

** (Mix) Could not start application phx_one_seven_grpc: PhxOneSevenGrpc.Application.start(:normal, []) returned an error: shutdown: failed to start child: GRPC.Server.Supervisor
    ** (EXIT) an exception was raised:
        ** (FunctionClauseError) no function clause matching in GRPC.Server.Supervisor.init/1
            (grpc 0.5.0) lib/grpc/server/supervisor.ex:41: GRPC.Server.Supervisor.init([endpoint: Helloworld.Endpoint, port: 50051])
            (stdlib 3.17) supervisor.erl:330: :supervisor.init/1
            (stdlib 3.17) gen_server.erl:423: :gen_server.init_it/2
            (stdlib 3.17) gen_server.erl:390: :gen_server.init_it/6
            (stdlib 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

To Reproduce Steps to reproduce the behavior:

1) Clone this repo phx_one_seven_grpc which contains the Phoenix 1.7.0-rc-0 project with elixir-grpc installed. 2) Run iex -S mix to run the Phoenix Server 3) Error will reproduce

Expected behavior ~A clear and concise description of what you expected to happen.~

Expected that the grpc server will start with Phoenix

Logs ~If applicable, add logs to help explain your problem.~

cj@cj-Z:~/projects/phx_one_seven_grpc|main ⇒  iex -S mix
Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit]

[notice] Application phx_one_seven_grpc exited: PhxOneSevenGrpc.Application.start(:normal, []) returned an error: shutdown: failed to start child: GRPC.Server.Supervisor
    ** (EXIT) an exception was raised:
        ** (FunctionClauseError) no function clause matching in GRPC.Server.Supervisor.init/1
            (grpc 0.5.0) lib/grpc/server/supervisor.ex:41: GRPC.Server.Supervisor.init([endpoint: Helloworld.Endpoint, port: 50051])
            (stdlib 3.17) supervisor.erl:330: :supervisor.init/1
            (stdlib 3.17) gen_server.erl:423: :gen_server.init_it/2
            (stdlib 3.17) gen_server.erl:390: :gen_server.init_it/6
            (stdlib 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
[notice] Application google_protos exited: :stopped
[notice] Application protobuf exited: :stopped
[notice] Application plug_cowboy exited: :stopped
[notice] Application cowboy_telemetry exited: :stopped
[notice] Application gettext exited: :stopped
[notice] Application telemetry_poller exited: :stopped
[notice] Application finch exited: :stopped
[notice] Application nimble_options exited: :stopped
[notice] Application nimble_pool exited: :stopped
[notice] Application mint exited: :stopped
[notice] Application hpax exited: :stopped
[notice] Application swoosh exited: :stopped
[notice] Application jason exited: :stopped
[notice] Application xmerl exited: :stopped
[notice] Application tailwind exited: :stopped
[notice] Application esbuild exited: :stopped
[notice] Application phoenix_live_dashboard exited: :stopped
[notice] Application telemetry_metrics exited: :stopped
[notice] Application heroicons exited: :stopped
[notice] Application phoenix_live_view exited: :stopped
[notice] Application phoenix_live_reload exited: :stopped
[notice] Application file_system exited: :stopped
[notice] Application phoenix_html exited: :stopped
[notice] Application postgrex exited: :stopped
[notice] Application ecto_sql exited: :stopped
[notice] Application db_connection exited: :stopped
[notice] Application connection exited: :stopped
[notice] Application phoenix_ecto exited: :stopped
[notice] Application ecto exited: :stopped
[notice] Application decimal exited: :stopped
[notice] Application phoenix exited: :stopped
[notice] Application castore exited: :stopped
[notice] Application websock_adapter exited: :stopped
[notice] Application websock exited: :stopped
[notice] Application phoenix_template exited: :stopped
[notice] Application phoenix_pubsub exited: :stopped
[notice] Application plug exited: :stopped
[notice] Application telemetry exited: :stopped
[notice] Application plug_crypto exited: :stopped
[notice] Application mime exited: :stopped
[notice] Application eex exited: :stopped
[notice] Application grpc exited: :stopped
[notice] Application gun exited: :stopped
[notice] Application cowboy exited: :stopped
[notice] Application ranch exited: :stopped
[notice] Application cowlib exited: :stopped
[notice] Application runtime_tools exited: :stopped
** (Mix) Could not start application phx_one_seven_grpc: PhxOneSevenGrpc.Application.start(:normal, []) returned an error: shutdown: failed to start child: GRPC.Server.Supervisor
    ** (EXIT) an exception was raised:
        ** (FunctionClauseError) no function clause matching in GRPC.Server.Supervisor.init/1
            (grpc 0.5.0) lib/grpc/server/supervisor.ex:41: GRPC.Server.Supervisor.init([endpoint: Helloworld.Endpoint, port: 50051])
            (stdlib 3.17) supervisor.erl:330: :supervisor.init/1
            (stdlib 3.17) gen_server.erl:423: :gen_server.init_it/2
            (stdlib 3.17) gen_server.erl:390: :gen_server.init_it/6
            (stdlib 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

~Protos~ ~If applicable, add protos to help explain your problem.~

Versions:

Additional context Add any other context about the problem here.

polvalente commented 1 year ago

Things should work if you use the github master branch instead of the Hex 0.5.0 version. Basically, we deprecated the global environment config in favor of a options-based config.

The issue is that you are using the new way in you application tree, but the code expects the old way.

Thanks for the report!

cdesch commented 1 year ago

You're welcome. So, just reference

{:grpc, git:  "https://github.com/elixir-grpc/grpc"}

for now instead of the following?

{:grpc, "~> 0.5.0"},

Is the plan for this change to be released in 0.6.0 ?

polvalente commented 1 year ago

You can either reference git or follow the instructions for 0.5 instead and it should be good to go.

Yes, everything after 0.5 on main will be eventually released on 0.6 :)