Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

[BUG] Upgrade from 2.x: EWMA rate limiter hits WRONGTYPE on sliding-window keys left in Redis

Ouverte
#930 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@chappie-daemon y travaille déjà.

Depuis le 23/10/2026.

  • #945 par @chappie-daemon — ouverte

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
55/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
redis, typescript
Domaine
backend, databases

Piste de recherche

Start by tracing the EWMA rate limiter’s Lua script and the code that builds its Redis keys; the issue names the colliding connection and message key patterns. Check how the existing sliding-window strategy stores those keys and inspect the upgrade notes. Done means upgrading with legacy sorted-set keys no longer causes WRONGTYPE errors, with the behavior covered for both connection and message limits.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Describe the bug
After upgrading from 2.x with the existing cache volume, client workers log on every new connection/message:

uncaught error: [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value script: <sha>, on @user_script:6.]

2.x used the sliding-window limiter, which stores ${remoteAddress}:connection:${period} and ${client}:message:${period} as sorted sets. Since #476 the default limits.rateLimiter.strategy is ewma, whose Lua script does HGET/HSET on the same key names. The old zset keys stay in Redis until their TTL expires (up to the longest configured period), and until then those clients hit the error path.

To Reproduce

  1. Run 2.x for a while (rate-limit keys accumulate in the cache volume).
  2. Upgrade to 3.x keeping the volume, start the relay.
  3. docker logs nostream shows the WRONGTYPE errors above; redis-cli type <ip>:connection:<period> → zset.

Expected behavior
Upgrading does not require manual Redis cleanup.

System

  • Version: 2.1.0 → 3.4.1, default rateLimiter.strategy: ewma, redis:7.0.5-alpine3.16

Workaround we used
Delete only the conflicting legacy keys (7 058 in our case), after which the errors stopped:

for p in '*:connection:*' '*:message:*'; do
  redis-cli -a "$REDIS_PASSWORD" --scan --pattern "$p" | while read k; do
    [ "$(redis-cli -a "$REDIS_PASSWORD" type "$k")" = zset ] && redis-cli -a "$REDIS_PASSWORD" del "$k"
  done
done

Suggestion
Either namespace the EWMA keys (e.g. ewma: prefix) so they cannot collide with sliding-window keys — this also helps when an operator switches strategy back and forth — or make the EWMA script self-healing:

if redis.call('TYPE', key).ok ~= 'hash' then redis.call('DEL', key) end

plus a line in the upgrade notes.

Langage dominant
TypeScript
Étoiles
829
Forks
234
Merge moyen
16 h 57 min
PR mergées (30 j)
76

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de cameri/nostream

Toutes les issues de cameri/nostream

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.