Skip to content

fix: bound the env apply so a slow server cannot stall the request (#211) - #222

Merged
puppe1990 merged 1 commit into
mainfrom
fix/env-write-timeout
Oct 5, 2026
Merged

puppe1990 merged 1 commit into
mainfrom
fix/env-write-timeout

Conversation

@puppe1990

Copy link
Copy Markdown
Collaborator

Problema (#211)

PUT /api/v1/apps/:id/env executa a gravação remota de forma síncrona dentro da request. Sem um teto de tempo, um servidor lento/indisponível (ou unit recém-criada, ver #213) mantinha a request aberta até ~32s até o proxy/cliente devolver 502.

Mudanças

Alternativa assíncrona (202 + job) foi considerada, mas muda o contrato do CLI/MCP; fica como evolução futura se o caso "apply demorado" voltar a incomodar.

Testes

  • mix test --exclude integration → 901 testes, 0 falhas
  • novos testes: timeout no EnvApply e 504 na API
  • format/credo/compile prod limpos

Closes #211.

)

- EnvApply runs the remote command under a 25s deadline and returns
  {:error, :timeout} instead of letting the request hang (configurable
  via :env_apply_timeout_ms)
- the readiness loop drops from 30s to 20s so a failed apply still
  returns the journal tail within the deadline
- API answers 504 env_apply_timeout on timeout; other applies keep 502
- apply failures log at warning level with the app slug

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
@puppe1990
puppe1990 merged commit bf48d8b into main Oct 5, 2026
1 check 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.

Painel: PUT /api/v1/apps/:id/env retorna 502 após ~32s (timeout na gravação de env)

1 participant