fix(eterra): increase default timeout 40s -> 120s for large geometry pages

- DEFAULT_TIMEOUT_MS: 40_000 -> 120_000 (1000 features with full geometry
  from Feleacu regularly exceed 40s on the eTerra server)
- Add timeoutMs option to syncLayer() for caller override
- syncLayer now passes timeoutMs through to EterraClient.create()

Fixes 'timeout of 40000ms exceeded' on TERENURI_ACTIVE sync.
This commit is contained in:
AI Assistant
2026-03-08 03:31:18 +02:00
parent d7d78c0cc1
commit 8bb4a47ac5
2 changed files with 6 additions and 2 deletions
@@ -59,7 +59,7 @@ type ProgressCallback = (downloaded: number, total?: number) => void;
const BASE_URL = "https://eterra.ancpi.ro/eterra";
const LOGIN_URL = `${BASE_URL}/api/authentication`;
const DEFAULT_TIMEOUT_MS = 40_000;
const DEFAULT_TIMEOUT_MS = 120_000;
const DEFAULT_PAGE_SIZE = 1000;
const PAGE_SIZE_FALLBACKS = [500, 200];
const MAX_RETRIES = 2;
@@ -54,6 +54,8 @@ export async function syncLayer(
/** When true, don't set terminal status (done/error) on progress store.
* Used when syncLayer runs as a sub-step of a larger export flow. */
isSubStep?: boolean;
/** Override the default HTTP timeout for the eTerra client (ms). */
timeoutMs?: number;
},
): Promise<SyncResult> {
const jobId = options?.jobId;
@@ -103,7 +105,9 @@ export async function syncLayer(
try {
push({ phase: "Conectare eTerra", downloaded: 0 });
const client = await EterraClient.create(username, password);
const client = await EterraClient.create(username, password, {
timeoutMs: options?.timeoutMs,
});
// Get UAT geometry for spatial-filtered layers
let uatGeometry;