mathieuprog / tz

Time zone support for Elixir
Apache License 2.0
125 stars 11 forks source link

print a warning but allow the app to start if there's an HTTP error #22

Closed mayel closed 7 months ago

mayel commented 9 months ago

Not sure if this is expected behaviour, but would be great to not block the app from starting:


** (Mix) Could not start application my_app: MyApp.Application.start(:normal, []) returned an error: shutdown: failed to start child: Tz.UpdatePeriodically
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, %Mint.HTTP1{host: "data.iana.org", port: 443, request: nil, streaming_request: nil, socket: {:sslsocket, {:gen_tcp, #Port<0.110>, :tls_connection, :undefined}, [#PID<0.1444.0>, #PID<0.1443.0>]}, transport: Mint.Core.Transport.SSL, mode: :active, scheme_as_string: "https", requests: {[], []}, state: :closed, buffer: "", proxy_headers: [], private: %{}, log: false}, %Mint.TransportError{reason: :closed}, []}
            (tz 0.26.2) lib/tz/http/mint/http_client.ex:30: Tz.HTTP.Mint.HTTPClient.recv_response/2
            (tz 0.26.2) lib/tz/http/mint/http_client.ex:18: Tz.HTTP.Mint.HTTPClient.request/2
            (tz 0.26.2) lib/tz/updater.ex:56: Tz.Updater.fetch_latest_iana_tz_version/0
            (tz 0.26.2) lib/tz/updater.ex:32: Tz.Updater.maybe_update_tz_database_to_latest_version/0
            (tz 0.26.2) lib/tz/updater.ex:14: Tz.Updater.maybe_recompile/0
            (tz 0.26.2) lib/tz/update_periodically.ex:31: Tz.UpdatePeriodically.init/1
            (stdlib 5.1.1) gen_server.erl:962: :gen_server.init_it/2
            (stdlib 5.1.1) gen_server.erl:917: :gen_server.init_it/6
mathieuprog commented 8 months ago

With this code change, how does it behave for the same error {:error, %Mint.HTTP1{ #...? What will be the output?

mayel commented 8 months ago

It triggers this log output: https://github.com/mathieuprog/tz/blob/master/lib/tz/updater.ex#L63