Skip to content

Commit

Permalink
Refactor FETCH_QUEUE_TTL parsing and improve error handling for tile …
Browse files Browse the repository at this point in the history
…metadata fetching
  • Loading branch information
dqunbp committed Nov 12, 2024
1 parent a5bf65d commit 54cfacb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/titiler_fetcher.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 54cfacb

Please sign in to comment.