From 017bb0d1465404ea8b9fc1efdc1941e4f2e518b4 Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Wed, 13 Mar 2019 12:07:59 -0700 Subject: [PATCH] wrap openid-config request in try/catch --- server/fxa.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/server/fxa.js b/server/fxa.js index 9e398f32..47d3bd6e 100644 --- a/server/fxa.js +++ b/server/fxa.js @@ -9,13 +9,17 @@ async function getFxaConfig() { if (fxaConfig && Date.now() - lastConfigRefresh < 1000 * 60 * 5) { return fxaConfig; } - const res = await fetch( - `${config.fxa_url}/.well-known/openid-configuration`, - { timeout: 3000 } - ); - fxaConfig = await res.json(); - fxaConfig.key_scope = KEY_SCOPE; - lastConfigRefresh = Date.now(); + try { + const res = await fetch( + `${config.fxa_url}/.well-known/openid-configuration`, + { timeout: 3000 } + ); + fxaConfig = await res.json(); + fxaConfig.key_scope = KEY_SCOPE; + lastConfigRefresh = Date.now(); + } catch (e) { + // continue with previous fxaConfig + } return fxaConfig; }