ajusta tratamento de saída de streams no DockerService para evitar travamentos e garantir a resolução de promessas

This commit is contained in:
Alexander Sabino 2026-05-07 11:56:28 +01:00
parent 007a87a536
commit ee7bec2d66
2 changed files with 14 additions and 3 deletions

View File

@ -489,13 +489,15 @@ class BackupService {
maxOkExitCode: 1,
onOutput: (line, stream) => {
const normalizedLine = String(line || '').trim();
if (!normalizedLine || stream !== 'stderr' || normalizedLine.startsWith('__DBKP_TAR_BEGIN__')) {
if (!normalizedLine || normalizedLine.startsWith('__DBKP_TAR_BEGIN__')) {
return;
}
if (!normalizedLine.startsWith('tar:')) {
// No helper (tar escreve em arquivo): lista de arquivos vai para stdout;
// avisos do tar vão para stderr.
if (stream === 'stdout' && !normalizedLine.startsWith('tar:')) {
fileCurrent += 1;
updateFileProgress(normalizedLine);
} else {
} else if (stream === 'stderr') {
pushLog(`Aviso do tar: ${normalizedLine}`, 'gerando-tar');
}
},

View File

@ -654,6 +654,15 @@ class DockerService {
await container.start();
const result = await container.wait();
// Destruir o attachStream para que os PassThrough streams emitam 'end'
// e as outputPromises possam resolver. Sem isso o runHelper trava indefinidamente.
if (attachStream && typeof attachStream.destroy === 'function') {
attachStream.destroy();
}
stdoutStream.end();
stderrStream.end();
await Promise.all(outputPromises);
output = output.trim();