From 3b4f851fc227773251a66c149e482c83f05e19c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Wed, 2 Dec 2026 16:40:38 -0300 Subject: [PATCH] fix: the page waits while the antivirus restarts instead of showing its English reason (DTF-WEB-2F) At 19:22 a customer read "Malware scanner unavailable; file remains blocked": the scan answered "error" (the antivirus not answering, likely restarting with the deploy), and the page treated it as final, while the worker scans an "error" file again a minute later (app/scanning.py). The page now keeps waiting through "error", within the same budget as a pending scan; only "rejected" stops at once, with its reason. Co-Authored-By: Claude Opus 5.5 --- tests/upload_retry_test.mjs | 16 ++++++++++++++++ web/upload.js | 6 +++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/upload_retry_test.mjs b/tests/upload_retry_test.mjs index 8eecb44..5c00245 100644 --- a/tests/upload_retry_test.mjs +++ b/tests/upload_retry_test.mjs @@ -210,6 +210,22 @@ const run = async (completeSteps, {abortAfter} = {}) => { const waits = delays.filter(d => d === 1000 || d === 5000); assert.ok(waits.filter(d => d === 1000).length === 150 && waits.includes(5000)); } +// The antivirus not answering (a deploy restarting it) is scanned again by the +// worker a minute later: the page waits through it (Sentry DTF-WEB-2F). +{ + scanStates = Array(70).fill('error'); + const {result, error} = await run([{}]); + assert.equal(error, undefined); + assert.equal(result, 'u1'); + scanStates = []; +} +// A refused file stops at once, with the server's reason. +{ + scanStates = ['pending', 'rejected']; + const {error} = await run([{}]); + assert.match(error?.message || '', /bloqueado pela verificação/); + scanStates = []; +} // A scan the server never finishes ends with the message, after its 15 minutes. { scanStates = Array(5000).fill('pending'); diff --git a/web/upload.js b/web/upload.js index d34124a..dabfccb 100644 --- a/web/upload.js +++ b/web/upload.js @@ -81,7 +81,11 @@ async function sendUpload(file, {api, prefix='/uploads', startPath=prefix, progr if(signal?.aborted)throw cancelled(); const checked=await api(prefix+'/'+id); if(checked.scan_state==='clean')return id; - if(['rejected','error'].includes(checked.scan_state))throw new Error(checked.scan_reason||'Arquivo bloqueado pela verificação de segurança.'); + if(checked.scan_state==='rejected')throw new Error(checked.scan_reason||'Arquivo bloqueado pela verificação de segurança.'); + // "error" is the antivirus not answering (restarting with a deploy): + // the worker scans the file again a minute later (app/scanning.py), so + // the page keeps waiting instead of showing the scanner's English + // reason (Sentry DTF-WEB-2F). progress('Verificando segurança de '+file.name+'…'); const pause=waited<150000?1000:5000; await new Promise(resolve=>setTimeout(resolve,pause));