From 8cd18d6b7bd1247d0ad04176b8a973f6369e1ea5 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Sat, 7 Dec 2019 15:31:33 +0100 Subject: [PATCH 1/4] Remove cached content if Promise rejected --- src/lib/content.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/content.js b/src/lib/content.js index 5b1c37a93..e28041e31 100644 --- a/src/lib/content.js +++ b/src/lib/content.js @@ -45,6 +45,11 @@ export function getContent([lang, name]) { .then(data => { data.fallback = fallback; return data; + }) + .catch(err => { + // eslint-disable-next-line no-console + console.log(err); + CACHE[url] = undefined; }); return (CACHE[url] = res); } From 0bad5d7d3d295dd5ac01581ec71b233f95d3998c Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Sat, 7 Dec 2019 15:37:05 +0100 Subject: [PATCH 2/4] DROP: debug --- src/lib/content.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/content.js b/src/lib/content.js index e28041e31..8f6a6e10b 100644 --- a/src/lib/content.js +++ b/src/lib/content.js @@ -20,6 +20,8 @@ export function getContent([lang, name]) { // In prod, never re-fetch the content (url is just a convenient compound cache key) if (process.env.NODE_ENV === 'production' && url in CACHE) { + // eslint-disable-next-line no-console + console.log(CACHE); return CACHE[url]; } From dff328eb3146e5516a2a732e0f06f753de2833db Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Sat, 7 Dec 2019 15:48:16 +0100 Subject: [PATCH 3/4] DROP: Disable caching completely --- src/lib/content.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/content.js b/src/lib/content.js index 8f6a6e10b..732429ba2 100644 --- a/src/lib/content.js +++ b/src/lib/content.js @@ -19,11 +19,11 @@ export function getContent([lang, name]) { if (!ext) url += '.md'; // In prod, never re-fetch the content (url is just a convenient compound cache key) - if (process.env.NODE_ENV === 'production' && url in CACHE) { - // eslint-disable-next-line no-console - console.log(CACHE); - return CACHE[url]; - } + // if (process.env.NODE_ENV === 'production' && url in CACHE) { + // // eslint-disable-next-line no-console + // console.log(CACHE); + // return CACHE[url]; + // } let fallback = false; const res = fetch(url) From 71870ed4c927823cfbb3162459101278f316ba38 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Sat, 7 Dec 2019 15:52:56 +0100 Subject: [PATCH 4/4] Bypass hydrator --- src/lib/hydrator.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/hydrator.js b/src/lib/hydrator.js index 340346c75..b57d3e6bd 100644 --- a/src/lib/hydrator.js +++ b/src/lib/hydrator.js @@ -50,8 +50,9 @@ class Hydrator extends Component { _render(props) { const { Child } = this; // hydrate on first run, then normal renders thereafter - const doRender = process.env.NODE_ENV!=='production' || this.hydrated ? render : hydrate; - doRender( + const doRender = + process.env.NODE_ENV !== 'production' || this.hydrated ? render : hydrate; + render( ,