Finch process is inaccessible when started from application.ex but works when started with Finch.start_link()

Hello, everyone,

I’m trying to get Finch working in my application to make HTTP requests to a third-party service. However, when I add Finch to my application.ex file in the children list like this:

{Finch,
  name: FinchProcess,
  pools: %{
    default: [
      conn_opts: [
        transport_opts: [
          ciphers: :ssl.cipher_suites(:default, :"tlsv1.2"),
          verify: :verify_none
        ]
      ]
    ]
  }
}

the process starts (I can see it in the observer) but calling Finch.request(FinchProcess) results in an error.

[debug] [__exception__: true, __struct__: ArgumentError, message: "unknown registry: FinchProcess"]

If I instead call Finch.start_link() at the beginning of my function, like this:

Finch.start_link(
  name: FinchProcess,
  pools: %{
    default: [
      conn_opts: [
        transport_opts: [
          ciphers: :ssl.cipher_suites(:default, :"tlsv1.2"),
          verify: :verify_none
        ]
      ]
    ]
  }
)

and then call Finch.request(FinchProcess) everything works fine.

Does anybody have an idea why starting Finch via the first method, in application.ex, would start the process but cause Finch.request() to not be able to find the process by name?

1 Like

Are you sure your function is executed after your application tree has started?

1 Like

I thought so, but apparently not. I just tried moving Finch up in my list of children and that seems to have solved the issue. Thanks.