From ebcc0c8b2afdecb2f8e57d0396cd015d37913a74 Mon Sep 17 00:00:00 2001 From: Max Goodhart Date: Sun, 21 Jun 2020 21:13:09 -0700 Subject: [PATCH] Add error handling to public data fetching --- src/node/data.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/node/data.js b/src/node/data.js index 212e592..47e3fa9 100644 --- a/src/node/data.js +++ b/src/node/data.js @@ -14,9 +14,14 @@ export async function* pollPublicData() { const publicDataURL = 'https://woke.net/csv' const refreshInterval = 5 * 60 * 1000 while (true) { - const resp = await fetch(publicDataURL) - const text = await resp.text() - const data = await csv().fromString(text) + let data + try { + const resp = await fetch(publicDataURL) + const text = await resp.text() + data = await csv().fromString(text) + } catch (err) { + console.warn('error loading stream data', err) + } yield filterLive(data) await sleep(refreshInterval) }