fix: pgvector format, robust error handling & 5-minute API timeout

This commit is contained in:
2026-03-31 18:58:38 -05:00
parent 81d3ba537f
commit fe2b8f5131
3 changed files with 67 additions and 15 deletions

View File

@ -5,8 +5,21 @@ async function request(path, options = {}) {
headers: { 'Content-Type': 'application/json' },
...options,
})
const data = await res.json()
if (!res.ok) throw new Error(data.error || `Error ${res.status}`)
// Protección: el servidor puede devolver texto/HTML en errores graves
let data
const contentType = res.headers.get('content-type') || ''
if (contentType.includes('application/json')) {
data = await res.json()
} else {
const text = await res.text()
data = { error: text || `Error del servidor (${res.status})` }
}
if (!res.ok) {
const msg = data.error || data.message || `Error ${res.status}`
throw new Error(data.paso ? `[${data.paso}] ${msg}` : msg)
}
return data
}