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

Aberta
#2,752 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 4 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
12/100
Tipo de issue
Bug
Clareza
Precisa de esclarecimento
Status de atividade
Ativa
Stack de tecnologia
docker, nodejs, postgresql, redis, typescript
Domínio
backend

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
TypeScript
Estrelas
10.2k
Forks
7.5k
Merge médio
6d 19h
PRs com merge (30d)
4

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de evolution-foundation/evolution-api

Todas as issues de evolution-foundation/evolution-api

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.