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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user