From 8081b7f89a61c39fe543b7a549c31ccb1778c410 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Tue, 26 Mar 2024 17:52:38 -0500 Subject: [PATCH] feat(ew): use NonRetriableError if stripe missing --- .../inngest/functions/sanity/product/sanity-product-created.ts | 3 ++- .../inngest/functions/sanity/product/sanity-product-deleted.ts | 3 ++- .../inngest/functions/sanity/product/sanity-product-updated.ts | 3 ++- apps/epic-web/src/inngest/functions/stripe/webhook-received.ts | 3 +-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/epic-web/src/inngest/functions/sanity/product/sanity-product-created.ts b/apps/epic-web/src/inngest/functions/sanity/product/sanity-product-created.ts index d2709ab83..e93cfe3f1 100644 --- a/apps/epic-web/src/inngest/functions/sanity/product/sanity-product-created.ts +++ b/apps/epic-web/src/inngest/functions/sanity/product/sanity-product-created.ts @@ -5,6 +5,7 @@ import {loadSanityProduct} from './index' import {sanityWriteClient} from 'utils/sanity-server' import {SANITY_WEBHOOK_EVENT} from '../sanity-inngest-events' import {paymentOptions} from 'pages/api/skill/[...skillRecordings]' +import {NonRetriableError} from 'inngest' const stripe = paymentOptions.providers.stripe?.paymentClient @@ -16,7 +17,7 @@ export const sanityProductCreated = inngest.createFunction( }, async ({event, step}) => { if (!stripe) { - throw new Error('Payment provider (Stripe) is missing') + throw new NonRetriableError('Payment provider (Stripe) is missing') } const sanityProduct = await step.run('get sanity product', async () => { diff --git a/apps/epic-web/src/inngest/functions/sanity/product/sanity-product-deleted.ts b/apps/epic-web/src/inngest/functions/sanity/product/sanity-product-deleted.ts index 690bff6eb..7d24b8d3c 100644 --- a/apps/epic-web/src/inngest/functions/sanity/product/sanity-product-deleted.ts +++ b/apps/epic-web/src/inngest/functions/sanity/product/sanity-product-deleted.ts @@ -2,6 +2,7 @@ import {inngest} from 'inngest/inngest.server' import {prisma} from '@skillrecordings/database' import {SANITY_WEBHOOK_EVENT} from '../sanity-inngest-events' import {paymentOptions} from 'pages/api/skill/[...skillRecordings]' +import {NonRetriableError} from 'inngest' const stripe = paymentOptions.providers.stripe?.paymentClient @@ -13,7 +14,7 @@ export const sanityProductDeleted = inngest.createFunction( }, async ({event, step}) => { if (!stripe) { - throw new Error('Payment provider (Stripe) is missing') + throw new NonRetriableError('Payment provider (Stripe) is missing') } const {productId} = event.data diff --git a/apps/epic-web/src/inngest/functions/sanity/product/sanity-product-updated.ts b/apps/epic-web/src/inngest/functions/sanity/product/sanity-product-updated.ts index bdbd8eff1..d47ca1ea5 100644 --- a/apps/epic-web/src/inngest/functions/sanity/product/sanity-product-updated.ts +++ b/apps/epic-web/src/inngest/functions/sanity/product/sanity-product-updated.ts @@ -4,6 +4,7 @@ import {v4} from 'uuid' import {loadSanityProduct} from './index' import {SANITY_WEBHOOK_EVENT} from '../sanity-inngest-events' import {paymentOptions} from 'pages/api/skill/[...skillRecordings]' +import {NonRetriableError} from 'inngest' const stripe = paymentOptions.providers.stripe?.paymentClient @@ -23,7 +24,7 @@ export const sanityProductUpdated = inngest.createFunction( }, async ({event, step}) => { if (!stripe) { - throw new Error('Payment provider (Stripe) is missing') + throw new NonRetriableError('Payment provider (Stripe) is missing') } const sanityProduct = await step.run('get sanity product', async () => { diff --git a/apps/epic-web/src/inngest/functions/stripe/webhook-received.ts b/apps/epic-web/src/inngest/functions/stripe/webhook-received.ts index de13ca447..c3d87d2f3 100644 --- a/apps/epic-web/src/inngest/functions/stripe/webhook-received.ts +++ b/apps/epic-web/src/inngest/functions/stripe/webhook-received.ts @@ -1,6 +1,5 @@ import {inngest} from 'inngest/inngest.server' import {STRIPE_WEBHOOK_RECEIVED_EVENT} from '@skillrecordings/inngest' -import {Redis} from '@upstash/redis' import {prisma} from '@skillrecordings/database' import {NonRetriableError} from 'inngest' import {postToSlack} from '@skillrecordings/skill-api' @@ -17,7 +16,7 @@ export const stripeWebhookReceived = inngest.createFunction( {event: STRIPE_WEBHOOK_RECEIVED_EVENT}, async ({event, step}) => { if (!stripe) { - throw new Error('Payment provider (Stripe) is missing') + throw new NonRetriableError('Payment provider (Stripe) is missing') } const stripeAccountId = await step.run(