Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/hex/oauth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defmodule Hex.OAuth do
alias Hex.API.OAuth

@refresh_cache __MODULE__.RefreshCache
@refresh_timeout 60_000

def start_link(_args) do
Hex.OnceCache.start_link(name: @refresh_cache)
Expand Down Expand Up @@ -41,11 +42,10 @@ defmodule Hex.OAuth do
{:ok, token_data["access_token"]}
else
# Token expired, use OnceCache to ensure only one refresh/auth happens
# Use infinity timeout because authentication may require user interaction
Hex.OnceCache.fetch(
@refresh_cache,
fn -> do_refresh_or_authenticate(token_data, opts) end,
timeout: :infinity
timeout: @refresh_timeout
)
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/hex/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule Hex.Repo do
@moduledoc false

@exchange_cache __MODULE__.ExchangeCache
@exchange_timeout 60_000
@hexpm_url "https://repo.hex.pm"
@hexpm_public_key """
-----BEGIN PUBLIC KEY-----
Expand Down Expand Up @@ -363,7 +364,8 @@ defmodule Hex.Repo do
Hex.OnceCache.fetch_key(
@exchange_cache,
{repo_name, repo_config.auth_key},
fn -> do_exchange_api_key(repo_config, repo_name) end
fn -> do_exchange_api_key(repo_config, repo_name) end,
timeout: @exchange_timeout
)
end
end
Expand Down
Loading