Cancel disconnected offer analysis and stop remaining provider calls

This commit is contained in:
2026-09-06 10:22:29 +03:00
parent 673d6c1bc8
commit d534ea20b9
10 changed files with 110 additions and 22 deletions
+2
View File
@@ -17,6 +17,7 @@ export async function analyzeInParts(input,runPart) {
const parts=splitAnalysisText(input.text),results=[],failures=[];
// Two requests at a time bounds provider pressure while processing every part.
for(let i=0;i<parts.length;i+=2) {
input.signal?.throwIfAborted();
await Promise.all(parts.slice(i,i+2).map(async part=>{
try {
const out=await runPart(part);
@@ -26,6 +27,7 @@ export async function analyzeInParts(input,runPart) {
catch(error){failures.push({part,error:String(error.message || error)});}
}));
}
input.signal?.throwIfAborted();
results.sort((a,b)=>a.part.index-b.part.index);
if(!results.length)throw new Error('Dokümanın hiçbir parçası analiz edilemedi.');
const merged={},issues=failures.map(f=>`${f.part.index+1}. parça analiz edilemedi.`);