Fix progress bar stuck at 30% during Cloud Run synchronous processing
Cloud Run processes PDFs synchronously (2-5 min). The await startCheck() call blocks JS, so progress never advanced past 30%. Add a setInterval timer before the await that advances through realistic stages every 18s, covering the full processing window. Timer is cleared on completion/error. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c4ffb94351
commit
5652b67a07
1 changed files with 25 additions and 1 deletions
26
js/upload.js
26
js/upload.js
|
|
@ -99,9 +99,32 @@ async function beginCheck() {
|
|||
const quickMode = document.getElementById('quickMode').checked;
|
||||
if (quickMode) addLog('Quick mode enabled — skipping expensive checks', 'info');
|
||||
|
||||
// Animate progress while Cloud Run processes synchronously (can take 2-5 min)
|
||||
const progressStages = [
|
||||
{ pct: 35, msg: 'Loading PDF structure...', log: 'Reading PDF metadata and tagging' },
|
||||
{ pct: 45, msg: 'Checking document structure...', log: 'Validating PDF tags and structure tree' },
|
||||
{ pct: 55, msg: 'Analyzing images with AI...', log: 'Running AI vision analysis on images' },
|
||||
{ pct: 65, msg: 'Checking color contrast...', log: 'Calculating WCAG contrast ratios' },
|
||||
{ pct: 72, msg: 'Analyzing readability...', log: 'Computing Flesch reading scores' },
|
||||
{ pct: 80, msg: 'Checking headings & links...', log: 'Heading hierarchy, tab order, role mapping' },
|
||||
{ pct: 88, msg: 'Running PDF/UA validation...', log: 'veraPDF structure validation' },
|
||||
{ pct: 94, msg: 'Compiling results...', log: 'Generating accessibility report' },
|
||||
];
|
||||
let stageIdx = 0;
|
||||
const progressTimer = setInterval(() => {
|
||||
if (stageIdx < progressStages.length) {
|
||||
const s = progressStages[stageIdx++];
|
||||
updateProgress(s.pct, s.msg);
|
||||
addLog(s.log, 'info');
|
||||
}
|
||||
}, 18000); // advance every 18s → covers ~2.5 min of processing
|
||||
|
||||
updateProgress(30, 'Analyzing PDF (this may take a few minutes)...');
|
||||
addLog('Sent to Cloud Run for processing...', 'info');
|
||||
|
||||
try {
|
||||
updateProgress(30, 'Analyzing PDF (this may take a few minutes)...');
|
||||
const result = await startCheck(currentJobId, quickMode);
|
||||
clearInterval(progressTimer);
|
||||
|
||||
if (result.success) {
|
||||
if (result.data && result.data.status === 'completed') {
|
||||
|
|
@ -121,6 +144,7 @@ async function beginCheck() {
|
|||
document.getElementById('progressContainer').style.display = 'none';
|
||||
}
|
||||
} catch (error) {
|
||||
clearInterval(progressTimer);
|
||||
addLog('Check error: ' + error.message, 'error');
|
||||
alert('Check failed: ' + error.message);
|
||||
document.getElementById('progressContainer').style.display = 'none';
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue