From 1d6e301b105691538c94fae57a5108bb84b0566b Mon Sep 17 00:00:00 2001 From: keyan Date: Thu, 12 Aug 2021 16:21:56 -0500 Subject: [PATCH] fix crashes and report which object failed in walletd --- api/resolvers/item.js | 4 +++- pages/api/capture/[[...path]].js | 9 +++++++-- pages/items/[id].js | 6 ++++++ walletd/index.js | 4 ++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/api/resolvers/item.js b/api/resolvers/item.js index a9bd7170..73a18b8a 100644 --- a/api/resolvers/item.js +++ b/api/resolvers/item.js @@ -122,7 +122,9 @@ export default { ${SELECT} FROM "Item" WHERE id = $1`, Number(id)) - item.comments = comments(models, id) + if (item) { + item.comments = comments(models, id) + } return item }, userComments: async (parent, { userId }, { models }) => { diff --git a/pages/api/capture/[[...path]].js b/pages/api/capture/[[...path]].js index 042983dc..3a5968bb 100644 --- a/pages/api/capture/[[...path]].js +++ b/pages/api/capture/[[...path]].js @@ -4,8 +4,13 @@ import path from 'path' export default async function handler (req, res) { const url = process.env.SELF_URL + '/' + path.join(...(req.query.path || [])) res.setHeader('Content-Type', 'image/png') - const streams = await new Pageres({ crop: true }) + try { + const streams = await new Pageres({ crop: true }) .src(url, ['600x300']) .run() - res.status(200).end(streams[0]) + res.status(200).end(streams[0]) + } catch(e) { + console.log(e) + res.status(500) + } } diff --git a/pages/items/[id].js b/pages/items/[id].js index 24b279ec..2993d5ec 100644 --- a/pages/items/[id].js +++ b/pages/items/[id].js @@ -13,6 +13,12 @@ import ApolloClient from '../../api/client' // ssr the item without comments so that we can populate metatags export async function getServerSideProps ({ req, params: { id } }) { + if (isNaN(id)) { + return { + notFound: true + } + } + const { error, data: { item } } = await (await ApolloClient(req)).query({ query: gql` diff --git a/walletd/index.js b/walletd/index.js index 00b02aff..49c6e6de 100644 --- a/walletd/index.js +++ b/walletd/index.js @@ -57,7 +57,7 @@ async function checkPendingInvoices () { const inv = await getInvoice({ id: invoice.hash, lnd }) await recordInvoiceStatus(inv) } catch (error) { - console.log(error) + console.log(invoice, error) process.exit(1) } }) @@ -106,7 +106,7 @@ async function checkPendingWithdrawls () { const wdrwl = await getPayment({ id: withdrawl.hash, lnd }) await recordWithdrawlStatus(withdrawl.id, wdrwl) } catch (error) { - console.log(error) + console.log(withdrawl, error) process.exit(1) } })