fix(parcel-sync): add 2min timeout to no-geom scan, non-blocking UI

- Server: Promise.race with 120s timeout on no-geom-scan API route
- Client: AbortController with 120s timeout on scan fetch
- UI: show 'max 2 min' during scanning + hint that buttons work without scan
- UI: timeout state shows retry button + explains no-geom won't be available
- Prevents indefinitely stuck 'Se scanează...' on slow eTerra responses
This commit is contained in:
AI Assistant
2026-03-08 02:28:51 +02:00
parent e57ca88e7e
commit d12f01fc02
2 changed files with 63 additions and 4 deletions
+15 -1
View File
@@ -48,9 +48,23 @@ export async function POST(req: Request) {
}
const client = await EterraClient.create(username, password);
const result = await scanNoGeometryParcels(client, siruta, {
// Global timeout: 2 minutes max for the entire scan
const scanPromise = scanNoGeometryParcels(client, siruta, {
workspacePk: body.workspacePk ?? null,
});
const timeoutPromise = new Promise<never>((_, reject) =>
setTimeout(
() =>
reject(
new Error(
"Scanare timeout — serverul eTerra răspunde lent. Reîncearcă mai târziu.",
),
),
120_000,
),
);
const result = await Promise.race([scanPromise, timeoutPromise]);
return NextResponse.json(result);
} catch (error) {