Skip to content

Commit

Permalink
Add 429 logging
Browse files Browse the repository at this point in the history
  • Loading branch information
zedeus committed Aug 30, 2023
1 parent 37b58a5 commit 282ce8b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/apiutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ template fetchImpl(result, fetchBody) {.dirty.} =
setLimited(account, api)
raise rateLimitError()
elif result.startsWith("429 Too Many Requests"):
echo "[accounts] 429 error, API: ", api, ", account: ", account.id
account.apis[api].remaining = 0
# rate limit hit, resets after the 15 minute window
raise rateLimitError()
Expand Down
2 changes: 1 addition & 1 deletion src/tokens.nim
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ proc invalidate*(account: var GuestAccount) =
if idx > -1: accountPool.delete(idx)
account = nil

proc release*(account: GuestAccount; invalid=false) =
proc release*(account: GuestAccount) =
if account.isNil: return
dec account.pending

Expand Down
2 changes: 0 additions & 2 deletions src/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ type
id*: string
oauthToken*: string
oauthSecret*: string
# init*: Time
lastUse*: Time
pending*: int
apis*: Table[Api, RateLimit]

Expand Down

0 comments on commit 282ce8b

Please sign in to comment.