fix: the page waits for the antivirus while the server can still be on the file (DTF-WEB-2E)
Some checks failed
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Failing after 8m39s
Build and deploy / Secret scan and release gate (push) Successful in 4s
Build and deploy / Publish images (push) Has been skipped

The worker scans one file at a time for every customer. On 2026-12-02 two
files were checked together, and the one waiting behind the other gave up
after two and a half minutes with "Verificação de segurança pendente"; its
budget counted only its own scan, not the queue. The page now waits the
file's own time plus the 15 minutes the worker gives one file before it
calls the scan stuck (SCAN_STUCK_SECONDS), polling each second for the
first two and a half minutes and then every five, and stops at once when
the customer removes the file. A scan that never ends still says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-12-02 14:56:25 -03:00
parent fe5e9c4f4a
commit cc460c6e0c
2 changed files with 36 additions and 6 deletions

View File

@@ -17,6 +17,7 @@ let calls;
let delays;
let fetches;
let onTimeout;
let scanStates = [];
globalThis.setTimeout = (fn, delay) => {
delays.push(delay);
@@ -58,7 +59,7 @@ const makeApi = completeSteps => {
if (step instanceof Error) throw step;
return step ?? {};
}
if (path === '/uploads/u1') return {scan_state: 'clean'};
if (path === '/uploads/u1') return {scan_state: scanStates.length ? scanStates.shift() : 'clean'};
throw new Error('caminho inesperado: ' + path);
};
};
@@ -198,4 +199,25 @@ const run = async (completeSteps, {abortAfter} = {}) => {
}
}
// The antivirus takes one file at a time for every customer: a file waiting
// behind others is still waited for, past the old two and a half minutes
// (Sentry DTF-WEB-2E), polling every 5 s after the first 150.
{
scanStates = Array(250).fill('pending');
const {result, error} = await run([{}]);
assert.equal(error, undefined);
assert.equal(result, 'u1');
const waits = delays.filter(d => d === 1000 || d === 5000);
assert.ok(waits.filter(d => d === 1000).length === 150 && waits.includes(5000));
}
// A scan the server never finishes ends with the message, after its 15 minutes.
{
scanStates = Array(5000).fill('pending');
const {error} = await run([{}]);
assert.match(error?.message || '', /Verificação de segurança pendente/);
const waited = delays.filter(d => d === 1000 || d === 5000).reduce((t, d) => t + d, 0);
assert.ok(waited >= 900000 && waited < 910000, 'waited ' + waited);
scanStates = [];
}
console.log('upload retry checks passed');