diff --git a/src/mosaic.mjs b/src/mosaic.mjs index 859dcd8..559eefd 100644 --- a/src/mosaic.mjs +++ b/src/mosaic.mjs @@ -171,7 +171,7 @@ async function mosaic512px(z, x, y, filters = {}) { const metadataByUuid = {}; await Promise.all( rows.map(async (row) => { - if (row && row.uuid) { + if (row?.uuid) { metadataByUuid[row.uuid] = await getGeotiffMetadata(row.uuid); } }) diff --git a/src/titiler_fetcher.mjs b/src/titiler_fetcher.mjs index f39f002..d430f03 100644 --- a/src/titiler_fetcher.mjs +++ b/src/titiler_fetcher.mjs @@ -44,6 +44,13 @@ async function enqueueTileFetching(tileUrl, z, x, y) { const request = tileRequestQueue .add(() => fetchTile(url), { priority: z, timeout: FETCH_QUEUE_TTL }) + .catch((error) => { + if (error.name === "TimeoutError") { + console.error(`Tile request timed out after ${FETCH_QUEUE_TTL}ms for URL: ${url}`); + } else { + console.error(`Error fetching tile: ${url}`, error); + } + }) .finally(() => { activeTileRequests.delete(url); }); @@ -64,7 +71,7 @@ async function fetchTileMetadata(uuid) { const metadata = await got(url.href).json(); return metadata; } catch (err) { - if (err.response && (err.response.statusCode === 404 || err.response.statusCode === 500)) { + if (err?.response?.statusCode in [404, 500]) { return null; } else { throw err;