diff --git a/src/index_theme.ts.template b/src/index_theme.ts.template index 2c415d004..1db4bc7b2 100644 --- a/src/index_theme.ts.template +++ b/src/index_theme.ts.template @@ -18,10 +18,20 @@ function webgl_support() { return false } } + +async function timeout(timeMS: number): Promise<{ layers: string[] }> { + await Utils.waitFor(timeMS) + return { layers: [] } +} + + async function getAvailableLayers(): Promise> { try { const host = new URL(Constants.VectorTileServer).host - const status = await Utils.downloadJson("https://" + host + "/summary/status.json") + const status = await Promise.any([ + Utils.downloadJson("https://" + host + "/summary/status.json"), + timeout(5000) + ]) return new Set(status.layers) } catch (e) { console.error("Could not get MVT available layers due to", e)