Skip to content

fix: resolve TS2304 build error - undefined maxRetries in whatsapp.baileys.service.ts#3

Merged
johanpedroo merged 2 commits into
mainfrom
copilot/fix-max-retries-variable
Apr 29, 2026
Merged

fix: resolve TS2304 build error - undefined maxRetries in whatsapp.baileys.service.ts#3
johanpedroo merged 2 commits into
mainfrom
copilot/fix-max-retries-variable

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 28, 2026

📋 Description

Docker image build was failing with error TS2304: Cannot find name 'maxRetries' at whatsapp.baileys.service.ts:1829. The variable was referenced in a log message inside the messages.update handler but never declared in scope.

Fix: Replace the undefined ${maxRetries} interpolation with the literal 3 in the log message — no retry logic exists at that callsite; the value was purely informational in the log string.

// Before (broken)
`Original message not found for update after ${maxRetries} retries. Skipping...`

// After (fixed)
`Original message not found for update after 3 retries. Skipping...`

🔗 Related Issue

🧪 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)

🧪 Testing

  • Manual testing completed
  • No breaking changes introduced

📸 Screenshots (if applicable)

✅ Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • My changes generate no new warnings
  • I have manually tested my changes thoroughly

📝 Additional Notes

Only the log message string is changed. No runtime behavior, retry logic, or control flow is affected.

Original prompt

O build da imagem Docker está falhando devido ao erro TS2304 em src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts, linha 1829: "Cannot find name 'maxRetries'". Corrija o erro declarando a variável maxRetries ou utilizando a abordagem correta para que a variável exista nesse escopo. Aparentemente, na linha 1829 (dentro do método 'messages.update'), há um log que utiliza ${maxRetries}, mas a variável não foi definida. A melhor abordagem é declarar let maxRetries = 3; próxima ao início do bloco relevante OU substituir por um número literal (ex: 3) se julgado adequado, para que o build do TypeScript seja concluído sem erros.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: ```
evolution-foundation#24 2.868 > evolution-api@2.3.7 build
evolution-foundation#24 2.868 > tsc --noEmit && tsup
evolution-foundation#24 2.868
evolution-foundation#24 106.3 src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts(1829,64): error TS2304: Cannot find name 'maxRetries'.
evolution-foundation#24 ERROR: process "/bin/sh -c NODE_OPTIONS="--max-old-space-size=2048" npm run build" did not complete successfully: exit code: 2

[builder 19/19] RUN NODE_OPTIONS="--max-old-space-size=2048" npm run build:
2.868
2.868 > evolution-api@2.3.7 build
2.868 > tsc --noEmit && tsup
2.868
106.3 src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts(1829,64): error TS2304: Cannot find name 'maxRetries'.


Dockerfile:34

32 | RUN ./Docker/scripts/generate_database.sh
33 |
34 | >>> RUN NODE_OPTIONS="--max-old-space-size=2048" npm run build
35 |
36 | FROM node:24-alpine AS final

ERROR: failed to build: failed to solve: process "/bin/sh -c NODE_OPTIONS="--max-old-space-size=2048" npm run build" did not complete successfully: exit code: 2
Reference
Check build summary support
Error: buildx failed with: ERROR: failed to build: failed to solve: process "/bin/sh -c NODE_OPTIONS="--max-old-space-size=2048" npm run build" did not complete successfully: exit code: 2

corrija esse erro no build da imagem

Assistant: O erro ocorre porque a variável maxRetries está sendo usada na linha 1829 do arquivo src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts, mas ela não foi declarada. O TypeScript acusa: error TS2304: Cannot find name 'maxRetries'.

Como corrigir:

1. Abra o arquivo src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts.
2. Vá até a linha 1829 e verifique o uso de maxRetries.
3. Corrija de uma das formas abaixo (escolha conforme a lógica do projeto):

- Se maxRetries deveria ser uma variável local, declare antes de usar, ex: let maxRetries = 3;
- Se pretendia acessar uma propriedade da classe, use this.maxRetries.
- Se é uma constante/import, certifique-se de importar/definir corretamente.

**Exemplo de correção rápida (caso seja uma propriedade da classe):**
Altere de:
```typescript
... maxRetries ...

Para:

... this.maxRetries ...

Se não souber o tipo ou valor esperado, temporariamente pode definir let maxRetries = 3; antes da linha 1829 para destravar o build, e depois ajustar conforme a lógica original.

Passos recomendados:

  • Corrija o uso de maxRetries no código.
  • Rode novamente o build (npm run build).
  • Refaça a build da imagem Docker.

Se precisar do trecho exato corrigido ou identificar automaticamente a linha, envie o conteúdo ao redor da linha 1829 desse arquivo que eu preparo a correção para você!

User: faça um PR para corrigir

Assistant: Estou criando um PR para corrigir o erro de build causado pelo uso de maxRetries não declarado no arquivo whatsapp.baileys.service.ts. Aguarde enquanto gero a correção.

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Fix error TS2304 by adding maxRetries variable fix: resolve TS2304 build error - undefined maxRetries in whatsapp.baileys.service.ts Apr 28, 2026
Copilot AI requested a review from johanpedroo April 28, 2026 23:01
@johanpedroo johanpedroo marked this pull request as ready for review April 29, 2026 00:01
@johanpedroo johanpedroo merged commit c9bcd75 into main Apr 29, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants