Memory grows linearly (~90 MB/h) until "JavaScript heap out of memory" with ~400 instances, most of them stuck in `connecting` (v2.3.7)

Aperta
#2,752 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
12/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Attiva
Stack tecnologico
docker, nodejs, postgresql, redis, typescript
Ambito
backend

Direzione di ricerca

The payload names no source files or tests. Start from the reporter's hypothesis: RxJS subscriptions held by instances stuck in connecting, especially the QR regeneration loop for sessions invalidated with 401, bounded by QRCODE_LIMIT. Reproduce by tracking heap growth per instance, and compare with #1419. Done means identifying which subscription or timer is not released and showing that RSS plateaus afterwards.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Environment

  • evoapicloud/evolution-api:v2.3.7, Docker Swarm, 6 GB container limit
  • NODE_OPTIONS=--max-old-space-size=3584 (later raised to 4096), PostgreSQL 14, Redis cache enabled
  • 413 instances: 62 open, 197 connecting (101 of them with disconnectionReasonCode 401, 62 never paired), 154 close
  • QRCODE_LIMIT=3000

Observed

Container RSS right after a restart: ~570 MB. It then grows linearly, day and night, at ~90 MB/h with no plateau:

  • 566 MB → 906 MB in 6 h
  • 566 MB → 1,298 MB in 8 h
  • 585 MB → 2,684 MB in 21 h

The growth rate does not depend on traffic (same slope at 02:00 as at 14:00).

After ~35 h of uptime the process died with:

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

In the minutes before, the Prisma pool was exhausted (P2024 storm), so the crash looks like the end of a slow leak plus a spike.

A daily restart (cron) keeps it under ~2.8 GB, so I'm using that as a workaround.

Question

v2.3.7 mentions a fix for a leak from multiple RxJS subscriptions, but this growth remains. Is there a known per-instance leak, especially for instances that sit in connecting (QR regeneration loop on sessions invalidated with 401)? Similar symptoms in #1419.

I'm testing QRCODE_LIMIT=60 to see whether the growth rate changes and will report back here.

Lingua principale
TypeScript
Stelle
10.2k
Fork
7.5k
Merge medio
6g 19h
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di evolution-foundation/evolution-api

Tutte le issue di evolution-foundation/evolution-api

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.