Skip to content

Commit 4608e7c

Browse files
committed
Add logging around 401 bucket locks, add DISABLE_401_LOCK unstable env var
1 parent b2a1609 commit 4608e7c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CONFIG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,10 @@ DNS address that will resolve to multiple members of the cluster. Does not need
4646

4747
If using Kubernetes, create a headless service and use it here for easy clustering.
4848

49-
Example: `nirn-headless.default.svc.cluster.local` or `nirn.mydomain.com`
49+
Example: `nirn-headless.default.svc.cluster.local` or `nirn.mydomain.com`
50+
51+
## Unstable env vars
52+
Collection of env vars that may be removed at any time, mainly used for Discord introducing new behaviour on their edge api versions
53+
54+
##### DISABLE_401_LOCK
55+
The proxy locks its queue permanently in case a 401 is encountered during normal operation. This env disables this mechanism but not the logging for it.

lib/queue.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,17 @@ func (q *RequestQueue) subscribe(ch *QueueChannel, path string, pathHash uint64)
347347

348348
if resp.StatusCode == 401 {
349349
// Permanently lock this queue
350-
atomic.StoreInt64(q.isTokenInvalid, 999)
350+
logger.WithFields(logrus.Fields{
351+
"bucket": path,
352+
"route": item.Req.URL.String(),
353+
"method": item.Req.Method,
354+
"identifier": q.identifier,
355+
"status": resp.StatusCode,
356+
}).Error("Received 401 during normal operation, assuming token is invalidated, locking bucket permanently")
357+
358+
if EnvGet("DISABLE_401_LOCK", "false") != "true" {
359+
atomic.StoreInt64(q.isTokenInvalid, 999)
360+
}
351361
}
352362
if remaining == 0 || resp.StatusCode == 429 {
353363
time.Sleep(time.Until(time.Now().Add(resetAfter)))

0 commit comments

Comments
 (0)