fix: a file the phone can no longer read says so in Portuguese and is picked again (DTF-WEB-2A)
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 7m51s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 58s
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 7m51s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 58s
Android Chrome threw NotReadableError reading a picked file (from Drive or Photos, after switching apps); the customer saw the browser's English text and "Tentar de novo", which reads the same dead file. The upload now says "não conseguimos ler este arquivo no aparelho. Escolha o arquivo de novo", the product page's button becomes "Escolher de novo" (the file leaves the list and the picker opens), and the cart summary shows no retry for it. upload_retry_test covers it and fails without the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -177,4 +177,22 @@ const run = async (completeSteps, {abortAfter} = {}) => {
|
||||
assert.equal(requested[0].options.method, 'DELETE');
|
||||
}
|
||||
|
||||
// A file the phone can no longer read (Android NotReadableError, DTF-WEB-2A):
|
||||
// the customer is told in Portuguese to pick it again, and nothing is sent.
|
||||
{
|
||||
const RealBlob = globalThis.Blob;
|
||||
globalThis.Blob = class extends RealBlob {
|
||||
arrayBuffer() { return Promise.reject(new DOMException('The requested file could not be read', 'NotReadableError')); }
|
||||
};
|
||||
try {
|
||||
const {result, error, calls} = await run([{}]);
|
||||
assert.equal(result, undefined);
|
||||
assert.equal(error?.unreadable, true);
|
||||
assert.match(error.message, /Escolha o arquivo de novo/);
|
||||
assert.equal(calls.length, 0, 'nothing reaches the server');
|
||||
} finally {
|
||||
globalThis.Blob = RealBlob;
|
||||
}
|
||||
}
|
||||
|
||||
console.log('upload retry checks passed');
|
||||
|
||||
@@ -288,7 +288,7 @@
|
||||
const p=enviar(file); p.catch(()=>{}); return p;
|
||||
},
|
||||
estado:file=>{const k=chaveArquivo(file),e=envios.get(k),f=falhas.get(k);
|
||||
return f?{fase:'falhou',erro:f.error?.message||'erro no envio'}
|
||||
return f?{fase:'falhou',erro:f.error?.message||'erro no envio',escolher:!!f.error?.unreadable}
|
||||
:!e?null:e.done?{fase:'pronto'}:e.sent>=file.size?{fase:'verificando'}:{fase:'enviando',enviado:e.sent};},
|
||||
deNovo:file=>{falhas.delete(chaveArquivo(file));enviar(file).catch(()=>{});pintaEnvio();},
|
||||
// A file already on the server (a saved sheet opened for editing): its id
|
||||
@@ -404,8 +404,12 @@
|
||||
if (el) {
|
||||
el.replaceChildren(document.createTextNode('Não foi possível enviar '+falhou[0].file.name+': '+
|
||||
(falhou[0].error?.message||'erro no envio').replace(/\.$/,'')+(falhou.length>1?' (e mais '+(falhou.length-1)+')':'')+'. '));
|
||||
// A file the phone cannot read again is picked again on its product
|
||||
// page; a retry here would read the same dead file (DTF-WEB-2A).
|
||||
if (!falhou[0].error?.unreadable) {
|
||||
const b=document.createElement('button'); b.type='button'; b.className='envioDeNovo'; b.textContent='Tentar de novo';
|
||||
b.onclick=tentaDeNovo; el.append(b);
|
||||
}
|
||||
el.classList.remove('ok'); el.classList.add('erro');
|
||||
}
|
||||
if (topo) topo.textContent='· falha no envio';
|
||||
|
||||
@@ -117,7 +117,7 @@ function pintaErrosDosArquivos(){
|
||||
texto.textContent='Não foi possível enviar '+item.f.name+': '+
|
||||
(estado.erro||'erro no envio').replace(/\.$/,'')+'.';
|
||||
const button=document.createElement('button');
|
||||
button.type='button';button.textContent='Tentar de novo';
|
||||
button.type='button';button.textContent=estado.escolher?'Escolher de novo':'Tentar de novo';
|
||||
button.dataset.envioCard=kind;button.dataset.envioIndex=String(index);
|
||||
box.append(texto,button);card.append(box);
|
||||
});
|
||||
@@ -140,7 +140,8 @@ function pintaEnvios(){
|
||||
return agora-enviadoEm.get(f)>ENVIADO_MS ? '' : '<div class="envio ok">'+icone('okCirculo')+'<span>'+nome+' enviado</span></div>';
|
||||
}
|
||||
if(e.fase==='falhou') return '<div class="envio erro"><span>Não foi possível enviar '+nome+': '+
|
||||
escapeHTML(e.erro.replace(/\.$/,''))+'.</span><button type="button" data-envio="'+i+'">Tentar de novo</button></div>';
|
||||
escapeHTML(e.erro.replace(/\.$/,''))+'.</span><button type="button" data-envio="'+i+'">'+
|
||||
(e.escolher?'Escolher de novo':'Tentar de novo')+'</button></div>';
|
||||
const pct=e.fase==='verificando' ? 100 : Math.floor(e.enviado/f.size*100);
|
||||
return '<div class="envio"><span>'+(e.fase==='verificando' ? 'Verificando a segurança de '+nome+'…'
|
||||
: 'Enviando '+nome+' · '+pct+'% · '+fmt(e.enviado)+' de '+fmt(f.size))+'</span>'+
|
||||
@@ -148,14 +149,25 @@ function pintaEnvios(){
|
||||
}).join('');
|
||||
}
|
||||
addEventListener('dtf-envio',agendaEnvios);
|
||||
// A failed upload goes again; one the phone can no longer read (Android,
|
||||
// DTF-WEB-2A) would fail the same way, so its file leaves the list and the
|
||||
// picker opens for the customer to choose it again.
|
||||
function refazEnvio(x, lista){
|
||||
if(!x) return;
|
||||
if(!dtfEnvio.estado(x.f)?.escolher){ dtfEnvio.deNovo(x.f); return; }
|
||||
const i=lista.indexOf(x);
|
||||
if(i>=0){ lista.splice(i,1); lista===folhas?pintaFolha():pintaArtes(); }
|
||||
$('inp').click();
|
||||
}
|
||||
$('envios').addEventListener('click',e=>{
|
||||
const b=e.target.closest('[data-envio]'); if(!b || !MODOS[modo]) return;
|
||||
const x=(ehFolha()?folhas:artes)[+b.dataset.envio]; if(x) dtfEnvio.deNovo(x.f);
|
||||
const lista=ehFolha()?folhas:artes;
|
||||
refazEnvio(lista[+b.dataset.envio], lista);
|
||||
});
|
||||
$('lista').addEventListener('click',e=>{
|
||||
const b=e.target.closest('[data-envio-card]'); if(!b || !window.dtfEnvio) return;
|
||||
const x=(b.dataset.envioCard==='folha'?folhas:artes)[+b.dataset.envioIndex];
|
||||
if(x) dtfEnvio.deNovo(x.f);
|
||||
const lista=b.dataset.envioCard==='folha'?folhas:artes;
|
||||
refazEnvio(lista[+b.dataset.envioIndex], lista);
|
||||
});
|
||||
// A sheet with residue gets its preview circled where the dots are.
|
||||
async function marcaResiduos(x){
|
||||
|
||||
@@ -15,7 +15,19 @@ function releaseUploadSlot(){
|
||||
async function sendUpload(file, {api, prefix='/uploads', startPath=prefix, progress=()=>{}, onBytes=()=>{}, scope='guest', resume=true, signal=null}) {
|
||||
const cancelled=()=>new DOMException('Envio cancelado.','AbortError');
|
||||
const samples=new Blob([file.slice(0,65536),file.slice(Math.max(0,file.size-65536))]);
|
||||
const hash=Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256',await samples.arrayBuffer())),b=>b.toString(16).padStart(2,'0')).join('');
|
||||
// A phone can lose the right to read a file it picked (Android: a file from
|
||||
// Drive or Photos, after switching apps). The browser's message is English
|
||||
// and a retry reads the same dead reference: picking the file again is the
|
||||
// way out (Sentry DTF-WEB-2A).
|
||||
let sampled;
|
||||
try{ sampled=await samples.arrayBuffer(); }
|
||||
catch(error){
|
||||
if(error?.name!=='NotReadableError' && error?.name!=='NotFoundError') throw error;
|
||||
const unreadable=new Error('não conseguimos ler este arquivo no aparelho. Escolha o arquivo de novo');
|
||||
unreadable.unreadable=true;
|
||||
throw unreadable;
|
||||
}
|
||||
const hash=Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256',sampled)),b=>b.toString(16).padStart(2,'0')).join('');
|
||||
const key='dtf-upload:'+JSON.stringify([scope,file.name,file.size,file.lastModified,hash]);
|
||||
// A busy server asks for a wait: retry this file alone, quietly, before the
|
||||
// customer sees the failure (Marcus, 2026-11-11). Only a 429 that carries
|
||||
|
||||
Reference in New Issue
Block a user