From 54cfacb14536aeffb3f8528df30dd1eadeffb20b Mon Sep 17 00:00:00 2001 From: dqunbp Date: Tue, 12 Nov 2024 16:37:06 +0400 Subject: [PATCH] Refactor FETCH_QUEUE_TTL parsing and improve error handling for tile metadata fetching --- src/titiler_fetcher.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/titiler_fetcher.mjs b/src/titiler_fetcher.mjs index edcb199..9931daf 100644 --- a/src/titiler_fetcher.mjs +++ b/src/titiler_fetcher.mjs @@ -34,7 +34,7 @@ async function fetchTile(url) { } } -const FETCH_QUEUE_TTL = parseInt(process.env.TILE_FETCH_TTL_MS, 10) || 1000 * 60 * 10; // 10 minutes default +const FETCH_QUEUE_TTL = Number.parseInt(process.env.TILE_FETCH_TTL_MS, 10) || 1000 * 60 * 10; // 10 minutes default async function enqueueTileFetching(tileUrl, z, x, y) { const url = tileUrl.replace("{z}", z).replace("{x}", x).replace("{y}", y); @@ -71,7 +71,7 @@ async function fetchTileMetadata(uuid) { const metadata = await got(url.href).json(); return metadata; } catch (err) { - if (err?.response?.statusCode in [404, 500]) { + if ([404, 500].includes(err?.response?.statusCode)) { return null; } else { throw err;