Gen Server seems to have silently died
TylerSustare opened this issue · 3 comments
I have a very standard Phoenix app I'm trying to interface with Firestore.
I was following along with this medium article . However, this article used Goth 1.2.
This is the repo I created in order to try this out. As you can see in the home page controller, I'm only calling Goth.fetch("https://www.googleapis.com/auth/datastore")
now. The commented code is what I was trying from the medium article with no luck.
When hitting the controller I'm getting the error that the process is not alive. I'm assuming this means the Goth
process because my Phx server is showing me an error page.
tl;dr error
** (exit) exited in: GenServer.call({:via, Registry, {Goth.Registry, "https://www.googleapis.com/auth/datastore"}}, :fetch, 5000)
** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
Click me
**stack trace**Exception:
** (exit) exited in: GenServer.call({:via, Registry, {Goth.Registry, "https://www.googleapis.com/auth/datastore"}}, :fetch, 5000)
** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
(elixir 1.14.5) lib/gen_server.ex:1027: GenServer.call/3
(ag_phx 0.1.0) lib/ag_phx_web/controllers/page_controller.ex:21: AgPhxWeb.PageController.home/2
(ag_phx 0.1.0) lib/ag_phx_web/controllers/page_controller.ex:1: AgPhxWeb.PageController.action/2
(ag_phx 0.1.0) lib/ag_phx_web/controllers/page_controller.ex:1: AgPhxWeb.PageController.phoenix_controller_pipeline/2
(phoenix 1.7.2) lib/phoenix/router.ex:430: Phoenix.Router.__call__/5
(ag_phx 0.1.0) lib/ag_phx_web/endpoint.ex:1: AgPhxWeb.Endpoint.plug_builder_call/2
(ag_phx 0.1.0) deps/plug/lib/plug/debugger.ex:136: AgPhxWeb.Endpoint."call (overridable 3)"/2
(ag_phx 0.1.0) lib/ag_phx_web/endpoint.ex:1: AgPhxWeb.Endpoint.call/2
(phoenix 1.7.2) lib/phoenix/endpoint/sync_code_reload_plug.ex:22: Phoenix.Endpoint.SyncCodeReloadPlug.do_call/4
(plug_cowboy 2.6.1) lib/plug/cowboy/handler.ex:11: Plug.Cowboy.Handler.init/2
(cowboy 2.10.0) /Users/tyler/go/src/github.com/tylersustare/ag_phx/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
(cowboy 2.10.0) /Users/tyler/go/src/github.com/tylersustare/ag_phx/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
(cowboy 2.10.0) /Users/tyler/go/src/github.com/tylersustare/ag_phx/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
(stdlib 4.3.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
I can verify that my google credentials are there from the IO.inspect
I put in start
I've been trying to use Goth with no luck at all. If this is a stupid mistake I'm making I apologize. I'm new to Elixir and I'm trying this because the Ruby clients for Firebase don't work with Ruby 3+.
I'm only calling
Goth.fetch("https://www.googleapis.com/auth/datastore")
This should have been Goth.fetch(MyApp.Goth)
, i.e. we pass the name of the Goth server we started in the app supervision tree. Or, following that article for Goth 1.2, you can use the deprecated function: Goth.Token.for_scope("https://www.googleapis.com/auth/datastore")
.
Hope this helps, please let us know otherwise!
Oh my goodness it totally worked! Thank you.
Calling Goth.fetch(MyApp.Goth)
worked like a charm 🎉
I'm keeping this repo up as a small example for others (and likely myself 😆) for the next time I need to set this up.
Turns out you will also see this if you don't replace the placeholder app name in the children list
{Goth, name: MyApp.Goth, source: source},