diff --git a/CHANGELOG.md b/CHANGELOG.md index 728fdfb4a..06f2d9e82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ #### Data migrations ### Changes - All changes from [v1.22.1](#v1221) and [v1.22.2](#v1222). +- [#960](https://github.com/LayerManager/layman/issues/960) Handle WMS requests with HTTP error more efficiently in timgen. ## v1.22.2 2023-11-10 diff --git a/timgen/src/map.js b/timgen/src/map.js index e8694e0bf..b2b67beca 100644 --- a/timgen/src/map.js +++ b/timgen/src/map.js @@ -91,11 +91,11 @@ const proxify_layer_loader = (layer, tiled, gs_public_url, gs_url, headers) => { }).then(res => { const headers = [...res.headers]; log(`load_fn.fetch_retry, res.status=${res.status}, headers=${JSON.stringify(headers, null, 2)}, image_url=${image_url}`) - if(res.headers.get('content-type').includes('text/xml')) { - return Promise.all([false, res.text()]) - } else { - return Promise.all([true, res.blob()]) - } + const is_xml = (res.headers.get('content-type') || '').includes('text/xml') + const ok = res.status < 400 && !is_xml + return Promise.all([ok, (ok ? res.blob() : res.text())]) + }).catch(reason => { + log(`load_fn.fetch_retry, catch reason=${reason}`) }); log(`load_fn.fetch_retry, loaded, ok=${ok}, image_url=${image_url}`)